diff --git a/README.md b/README.md index b4edbfb3b..1cbca3c83 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ You can set additional options: Usage: js-slang [PROGRAM_STRING] [OPTION] -c, --chapter=CHAPTER set the Source chapter number (i.e., 1-4) (default: 1) - -v, --variant=VARIANT set the Source variant (i.e., default, interpreter, substituter, typed, concurrent, wasm) (default: default) + -v, --variant=VARIANT set the Source variant (i.e., default, interpreter, substituter, typed, wasm) (default: default) -h, --help display this help -e, --eval don't show REPL, only display output of evaluation ``` @@ -81,7 +81,6 @@ Currently, valid CHAPTER/VARIANT combinations are: - `--chapter=2 --variant=interpreter` - `--chapter=2 --variant=typed` - `--chapter=3 --variant=default` -- `--chapter=3 --variant=concurrent` - `--chapter=3 --variant=interpreter` - `--chapter=3 --variant=typed` - `--chapter=4 --variant=default` diff --git a/docs/lib/concurrency.js b/docs/lib/concurrency.js deleted file mode 100644 index 75fa7c269..000000000 --- a/docs/lib/concurrency.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Setup multiple threads for concurrent execution. For each - * function f_i, - * setup a thread t_i that executes the body of - * f_i. Any parameters of f_i refer - * to undefined during execution. - * The thread that called concurrent_execute - * runs concurrently with all t_i. Returns - * undefined. This is an atomic operation. - * @param {function} f_1,f_2,...,f_n - given functions - * @returns {undefined} undefined - */ -function concurrent_execute() {} - -/** - * Assumes the head of pair p is a boolean - * b. Sets the head of p to - * true. Returns b. This is an - * atomic operation. - * @param {array} p - given pair - * @returns {value} - head of pair b - */ -function test_and_set(p) {} - -/** - * Sets the head of pair p to - * false. Returns undefined. - * This is an atomic operation. - * @param {array} p - given pair - * @returns {undefined} undefined - */ -function clear(p) {} diff --git a/docs/md/README_3_CONCURRENT.md b/docs/md/README_3_CONCURRENT.md deleted file mode 100644 index c4147ab00..000000000 --- a/docs/md/README_3_CONCURRENT.md +++ /dev/null @@ -1,62 +0,0 @@ -Source §3 Concurrent is a small programming language, designed for the third chapter -of the textbook -Structure and Interpretation -of Computer Programs, JavaScript Adaptation (SICP JS). - -## What names are predeclared in Source §3 Concurrent? - -On the right, you see all predeclared names of Source §3 Concurrent, in alphabetical -order. Click on a name to see how it is defined and used. They come in these groups: - - -## What can you do in Source §3 Concurrent? - -You can use all features of -Source §3 and all -features that are introduced in -chapter 3.4 of the -textbook. -Below are the features that Source §3 Concurrent adds to Source §3. - -### Concurrency - -To introduce concurrency into your programs, you can use the -functions in the CONCURRENCY library. The program -runs concurrently with the threads that it creates. The program terminates when -all threads terminate. Any result value from any of the threads, including the -program's thread, are ignored. Use the predeclared `display` function to display -result values. - -## You want the definitive specs? - -For our development team, we are maintaining a definitive description -of the language, called the -Specification of Source §3 Concurrent. Feel free to -take a peek! - - diff --git a/docs/md/README_CONCURRENCY.md b/docs/md/README_CONCURRENCY.md deleted file mode 100644 index e3a1f28e7..000000000 --- a/docs/md/README_CONCURRENCY.md +++ /dev/null @@ -1,10 +0,0 @@ -CONCURRENCY provides three functions for introducing concurrency. -Click on a name on the right to see how they are defined and used. - -Concurrency is covered in -the textbook -Structure and Interpretation -of Computer Programs, JavaScript Adaptation (SICP JS) -in -section 3.4.2 Mechanisms for Controlling Concurrency. - diff --git a/docs/md/README_top.md b/docs/md/README_top.md index 33aedac01..17e62e591 100644 --- a/docs/md/README_top.md +++ b/docs/md/README_top.md @@ -31,8 +31,6 @@ the members of our learning community. #### Source §2 Typed -#### Source §3 Concurrent - #### Source §3 Typed #### Source §4 Typed @@ -58,8 +56,6 @@ the Source Academy. #### Specification of Source §2 Typed -#### Specification of Source §3 Concurrent - #### Specification of Source §3 Typed #### Specification of Source §4 Typed diff --git a/docs/specs/Makefile b/docs/specs/Makefile index 9c90edd42..30cf44087 100644 --- a/docs/specs/Makefile +++ b/docs/specs/Makefile @@ -1,6 +1,6 @@ PDFLATEX = latexmk -pdf -SPECSNUMS = 1 1_wasm 1_type_inference 1_infinite_loop_detection 1_typed 2 2_typed 3_type_inference 3 3_concurrent 3_typed 4 4_explicitcontrol 4_typed styleguide 2_stepper studio_2 python_1 +SPECSNUMS = 1 1_wasm 1_type_inference 1_infinite_loop_detection 1_typed 2 2_typed 3_type_inference 3 3_typed 4 4_explicitcontrol 4_typed styleguide 2_stepper studio_2 python_1 SPECS = $(SPECSNUMS:%=source_%) diff --git a/docs/specs/source_3_concurrent.tex b/docs/specs/source_3_concurrent.tex deleted file mode 100644 index 6631becee..000000000 --- a/docs/specs/source_3_concurrent.tex +++ /dev/null @@ -1,106 +0,0 @@ -\input source_header.tex - -\begin{document} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - \docheader{2021}{Source}{\S 3 Concurrent}{Jonathan Chan, Martin Henz, Koo Zhengqun} - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -\input source_intro.tex - -Source \S 3 Concurrent is a concurrent extension of Source \S 3. - -\section{Changes} - -Source \S 3 Concurrent modifies Source \S 3 in the following ways: -\begin{itemize} -\item Concurrency support functions are added, see Section~\textbf{Concurrency Support} on page \pageref{conc_supp}. -\item The given program starts in a thread that runs concurrently with any - threads that are created during the execution of the program. -\item Neither the thread of the give program nor any other threads produce - any values as results. Their effect is observable through \emph{side effects} - such as calls of the \lstinline{display} primitive. - \item Import directives are currently not supported. -\end{itemize} -\noindent -The concurrency of Source \S 3 Concurrent is thread-based and deviates -from the event-driven concurrency of -\href{http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf}{\color{DarkBlue} - ECMAScript 2018 ($9^{\textrm{th}}$ Edition)}. Source \S 3 Concurrent is -motivated by Section 3.4 of the textbook -\href{https://sourceacademy.org/sicpjs}{\color{DarkBlue}\emph{Structure and Interpretation -of Computer Programs}, JavaScript Adaptation}. - -\section{Concurrency} - -We specify \emph{interleaving semantics} for Source \S 3 Concurrent. -The effect of executing a Source \S 3 Concurrent program -should be explainable as a single sequence of atomic actions. Each thread -specifies a particular sequence of actions in a specific order, -and the implementation is free to interleave the sequences of the threads -into a single sequence, as long as the following conditions are met: -\begin{enumerate} -\item The order of actions within each thread is respected (sequential - threads). -\item Any action that is included in any thread's sequence of actions will - eventually be executed (no starvation). -\end{enumerate} -\noindent -The atomic actions are primitive steps such as accessing the value of a name, -accessing a data structure, reducing a conditional expression or statement, -carrying out a primitive operation or calling a function. Such atomic actions -are considered \emph{uninterruptible}; they specify the \emph{granularity} -of the concurrency. - -\input source_bnf.tex - -\newpage - -\input source_3_bnf_without_import.tex - -\newpage - -\input source_return - -\input source_boolean_operators - -\input source_loops - -\input source_names_lang - -\input source_numbers - -\input source_strings - -\input source_arrays - -\input source_comments - -\input source_typing_3 - -\input source_standard - -\input source_misc - -\input source_math - -\input source_concurrency - -\input source_lists - -\input source_pair_mutators - -\input source_array_support - -\input source_streams - -\input source_js_differences - -\newpage - -\input source_list_library - -\newpage - -\input source_stream_library - - \end{document} diff --git a/docs/specs/source_concurrency.tex b/docs/specs/source_concurrency.tex deleted file mode 100644 index 632810695..000000000 --- a/docs/specs/source_concurrency.tex +++ /dev/null @@ -1,9 +0,0 @@ -\subsection*{Concurrency Support} -\label{conc_supp} -The following concurrency support is provided: - -\begin{itemize} -\item \(\texttt{concurrent\_execute(}\texttt{f}_\texttt{1}, \cdots \texttt{f}_\texttt{n}\texttt{)}\): \(\textit{primitive}\), setup multiple threads for concurrent execution. For each nullary function \(\texttt{f}_\texttt{i}\) that returns \texttt{undefined}, setup a thread \(\texttt{t}_\texttt{i}\) that executes the code in the body of \(\texttt{f}_\texttt{i}\). The thread that called \texttt{concurrent\_execute} also executes concurrently with all \(\texttt{t}_\texttt{i}\). Returns \texttt{undefined}. This is an atomic operation. -\item \texttt{test\_and\_set(p)}: \(\textit{primitive}\), assumes the head of pair \texttt{p} is a boolean \(b\). Sets the head of \texttt{p} to \texttt{true}. Returns \(b\). This is an atomic operation. -\item \texttt{clear(p)}: \(\textit{primitive}\), sets the head of pair \texttt{p} to \texttt{false}. Returns \texttt{undefined}. This is an atomic operation. -\end{itemize} diff --git a/scripts/autocomplete.mjs b/scripts/autocomplete.mjs index 34de8e977..d3e07482e 100644 --- a/scripts/autocomplete.mjs +++ b/scripts/autocomplete.mjs @@ -18,7 +18,6 @@ const TARGETS = [ "source_2", "source_2_typed", "source_3", - "source_3_concurrent", "source_3_typed", "source_4", "source_4_typed", diff --git a/scripts/docs.mjs b/scripts/docs.mjs index 70f0faef0..bd592b606 100644 --- a/scripts/docs.mjs +++ b/scripts/docs.mjs @@ -71,20 +71,6 @@ const configs = { "pairmutator.js" ] }, - "Source §3 Concurrent": { - "readme": "README_3_CONCURRENT.md", - "dst": "source_3_concurrent/", - "libs": [ - "auxiliary.js", - "misc.js", - "math.js", - "list.js", - "stream.js", - "array.js", - "pairmutator.js", - "concurrency.js" - ] - }, "Source §3 Typed": { "readme": "README_3_TYPED.md", "dst": "source_3_typed/", @@ -190,13 +176,6 @@ const configs = { "pairmutator.js" ] }, - "CONCURRENCY": { - "readme": "README_CONCURRENCY.md", - "dst": "CONCURRENCY/", - "libs": [ - "concurrency.js" - ] - }, "MCE": { "readme": "README_MCE.md", "dst": "MCE/", diff --git a/src/__tests__/__snapshots__/block-scoping.ts.snap b/src/__tests__/__snapshots__/block-scoping.ts.snap deleted file mode 100644 index dc267db9d..000000000 --- a/src/__tests__/__snapshots__/block-scoping.ts.snap +++ /dev/null @@ -1,216 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Cannot overwrite loop variables within a block: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let z = []; - for (let x = 0; x < 2; x = x + 1) { - x = 1; - } - return false; -} -test();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Assignment to a for loop variable in the for loop is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when accessing temporal dead zone: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = 1; -function f() { - display(a); - const a = 5; -} -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name a declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`In a block, every going-to-be-defined variable in the block cannot be accessed until it has been defined in the block.: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = 1; -{ - a + a; - const a = 10; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name a declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No hoisting of functions. Only the name is hoisted like let and const: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const v = f(); -function f() { - return 1; -} -v;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name f declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Shadowed variables may not be assigned to until declared in the current scope: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let variable = 1; -function test(){ - variable = 100; - let variable = true; - return variable; -} -test();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name variable not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`const uses block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - const x = true; - if(true) { - const x = false; - } else { - const x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for loop \`let\` variables are copied into the block scope: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let z = []; - for (let x = 0; x < 10; x = x + 1) { - z[x] = () => x; - } - return z[1](); -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for loops use block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - for (let x = 1; x > 0; x = x - 1) { - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`let uses block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - if(true) { - let x = false; - } else { - let x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standalone block statements: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - const x = true; - { - const x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`while loops use block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - while (true) { - let x = false; - break; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/display.ts.snap b/src/__tests__/__snapshots__/display.ts.snap deleted file mode 100644 index 17d11e49e..000000000 --- a/src/__tests__/__snapshots__/display.ts.snap +++ /dev/null @@ -1,184 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`display can be used to display (escaped) strings: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(\\"Tom's assisstant said: \\\\\\"tuna.\\\\\\"\\");", - "displayResult": Array [ - "\\"Tom's assisstant said: \\\\\\"tuna.\\\\\\"\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "Tom's assisstant said: \\"tuna.\\"", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display arrays: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display([1, 2, [4, 5]]);", - "displayResult": Array [ - "[1, 2, [4, 5]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - 2, - Array [ - 4, - 5, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display functions: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(x => x); display((x, y) => x + y);", - "displayResult": Array [ - "x => x", - "(x, y) => x + y", - ], - "numErrors": 0, - "parsedErrors": "", - "result": [Function], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display funny numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(1e38); display(NaN); display(Infinity);", - "displayResult": Array [ - "1e+38", - "NaN", - "Infinity", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Infinity, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display lists: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(list(1, 2));", - "displayResult": Array [ - "[1, [2, null]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - 2, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(0);", - "displayResult": Array [ - "0", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display can be used to display objects: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display({a: 1, b: 2, c: {d: 3}});", - "displayResult": Array [ - "{\\"a\\": 1, \\"b\\": 2, \\"c\\": {\\"d\\": 3}}", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Object { - "a": 1, - "b": 2, - "c": Object { - "d": 3, - }, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display second argument can be a string: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(31072020, \\"my_first_String\\");", - "displayResult": Array [ - "my_first_String 31072020", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 31072020, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display throw error if second argument is non-string when used: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "display(31072020, 0xDEADC0DE);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: TypeError: display expects the second argument to be a string", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`display with no arguments throws an error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "display();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 or more arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`raw_display can be used to display (unescaped) strings directly: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "raw_display(\\"Tom's assisstant said: \\\\\\"tuna.\\\\\\"\\");", - "displayResult": Array [ - "Tom's assisstant said: \\"tuna.\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "Tom's assisstant said: \\"tuna.\\"", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/draw_data.ts.snap b/src/__tests__/__snapshots__/draw_data.ts.snap deleted file mode 100644 index 065789fe5..000000000 --- a/src/__tests__/__snapshots__/draw_data.ts.snap +++ /dev/null @@ -1,49 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`draw_data returns first argument if exactly one argument: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "draw_data(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [ - Array [ - 1, - ], - ], -} -`; - -exports[`draw_data returns first argument if more than one argument: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "draw_data(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [ - Array [ - 1, - 2, - ], - ], -} -`; - -exports[`draw_data with no arguments throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "draw_data();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 or more arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/index.ts.snap b/src/__tests__/__snapshots__/index.ts.snap index 2339d62aa..6c7570d78 100644 --- a/src/__tests__/__snapshots__/index.ts.snap +++ b/src/__tests__/__snapshots__/index.ts.snap @@ -1,230 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Accessing array with nonexistent index returns undefined: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = []; -a[1];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Accessing object with nonexistent property returns undefined: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = {}; -o.nonexistent;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Allow display to return value it is displaying: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "25*(display(1+1));", - "displayResult": Array [ - "2", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 50, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Array assignment has value: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let arr = []; -const a = arr[0] = 1; -const b = arr[1] = arr[2] = 4; -arr[0] === 1 && arr[1] === 4 && arr[2] === 4;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Arrays toString matches up with JS: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "toString([1, 2]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "1,2", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Arrow function definition returns itself: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "() => 42;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": [Function], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Arrow function infinite recursion with list args represents CallExpression well: expectParsedErrorNoErrorSnapshot 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = xs => append(f(xs), list()); -f(list(1, 2));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Maximum call stack size exceeded - f([1, [2, null]]).. f([1, [2, null]]).. f([1, [2, null]])..", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Assignment has value: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let a = 1; -let b = a = 4; -b === 4 && a === 4;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins hide their implementation when stringify: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(pair);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "function pair(left, right) { - [implementation hidden] -}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins hide their implementation when toString: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "toString(pair);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "function pair(left, right) { - [implementation hidden] -}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Can overwrite lets when assignment is allowed: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test() { - let variable = false; - variable = true; - return variable; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot overwrite consts even when assignment is allowed: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - const constant = 3; - constant = 4; - return constant; -} -test();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Cannot assign new value to constant constant.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Deep object assignment and retrieval: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = {}; -o.a = {}; -o.a.b = {}; -o.a.b.c = \\"string\\"; -o.a.b.c;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "string", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Empty code returns undefined: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Factorial arrow function: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const fac = (i) => i === 1 ? 1 : i * fac(i-1); -fac(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 120, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - exports[`Find arrow function declaration 1`] = ` SourceLocation { "end": Position { @@ -547,561 +322,3 @@ SourceLocation { }, } `; - -exports[`Function infinite recursion with list args represents CallExpression well: expectParsedErrorNoErrorSnapshot 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(xs) { return append(f(xs), list()); } -f(list(1, 2));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Maximum call stack size exceeded - f([1, [2, null]]).. f([1, [2, null]]).. f([1, [2, null]])..", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Functions passed into non-source functions remain equal: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function t(x, y, z) { - return x + y + z; -} -identity(t) === t && t(1, 2, 3) === 6;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Multiline string self-evaluates to itself: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "\`1 -1\`;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "1 -1", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Objects toString matches up with JS: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "toString({a: 1});", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[object Object]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Rest parameters work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function rest(a, b, ...c) { - let sum = a + b; - for (let i = 0; i < array_length(c); i = i + 1) { - sum = sum + c[i]; - } - return sum; -} -rest(1, 2); // no error -rest(1, 2, ...[3, 4, 5], ...[6, 7], ...[]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 28, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Simple arrow function infinite recursion represents CallExpression well: expectParsedErrorNoErrorSnapshot 1`] = ` -Object { - "alertResult": Array [], - "code": "(x => x(x)(x))(x => x(x)(x));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Maximum call stack size exceeded - x(x => x(x)(x)).. x(x => x(x)(x)).. x(x => x(x)(x))..", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Simple function infinite recursion represents CallExpression well: expectParsedErrorNoErrorSnapshot 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) {return x(x)(x);} f(f);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Maximum call stack size exceeded - x(function f(x) { - return x(x)(x); -}).. x(function f(x) { - return x(x)(x); -}).. x(function f(x) { - return x(x)(x); -})..", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Simple object assignment and retrieval: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = {}; -o.a = 1; -o.a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Single boolean self-evaluates to itself: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Single number self-evaluates to itself: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "42;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 42, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Single string self-evaluates to itself: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "'42';", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "42", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test apply_in_underlying_javascript: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "apply_in_underlying_javascript((a, b, c) => a * b * c, list(2, 5, 6));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 60, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test context reuse: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 0; -function f() { - i = i + 1; - return i; -} -i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test context reuse: expectResult 2`] = ` -Object { - "alertResult": Array [], - "code": "i = 100; f();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 101, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test context reuse: expectResult 3`] = ` -Object { - "alertResult": Array [], - "code": "f(); i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 102, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test context reuse: expectResult 4`] = ` -Object { - "alertResult": Array [], - "code": "i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 102, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test equal for different lists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "!equal(list(1, 2), pair(1, 2)) && !equal(list(1, 2, 3), list(1, list(2, 3)));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test equal for lists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(list(1, 2), pair(1, pair(2, null))) && equal(list(1, 2, 3, 4), list(1, 2, 3, 4));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Test equal for primitives: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(1, 1) && equal(\\"str\\", \\"str\\") && equal(null, null) && !equal(1, 2) && !equal(\\"str\\", \\"\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`false if with empty else works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (false) { -} else { -}", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`false if with nonempty if works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (false) { -} else { - 2; -}", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`functions toString (mostly) matches up with JS: expect to loosely match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return 5; -} -toString(a=>a) + toString(f);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "a => afunction f(x) { - return 5; -}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`parseError for missing semicolon: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "42", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing semicolon at the end of statement", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parseError for template literals with expressions: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\`\${1}\`;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expressions are not allowed in template literals (\`multiline strings\`)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitives toString matches up with JS: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "toString(true) + -toString(false) + -toString(1) + -toString(1.5) + -toString(null) + -toString(undefined) + -toString(NaN);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "truefalse11.5nullundefinedNaN", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test && shortcircuiting: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false && 1();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test || shortcircuiting: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true || 1();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test false && false: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false && false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test false && true: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false && true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test false || false: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false || false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test false || true: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false || true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test false conditional expression: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "false ? true : false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test true && false: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true && false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test true && true: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true && true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test true || false: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true || false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test true || true: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true || true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`test true conditional expression: expect to match JS 1`] = ` -Object { - "alertResult": Array [], - "code": "true ? true : false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`true if with empty if works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) { -} else { -}", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`true if with nonempty if works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) { - 1; -} else { -}", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/inspect.ts.snap b/src/__tests__/__snapshots__/inspect.ts.snap deleted file mode 100644 index ee1749372..000000000 --- a/src/__tests__/__snapshots__/inspect.ts.snap +++ /dev/null @@ -1,2761 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`debugger; pauses for 1`] = ` -Object { - "head": Object { - "i": 0, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 2`] = ` -Object { - "head": Object { - "_copy_of_i": 0, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 3`] = ` -Object { - "head": Object { - "i": 0, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 4`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 10, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 82, - "loc": SourceLocation { - "end": Position { - "column": 7, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "x": 10, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; pauses for 5`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 6`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses for 7`] = `""`; - -exports[`debugger; pauses while 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 10, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 8, - }, - "start": Position { - "column": 2, - "line": 8, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 82, - "loc": SourceLocation { - "end": Position { - "column": 7, - "line": 8, - }, - "start": Position { - "column": 2, - "line": 8, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "x": 10, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; pauses while 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses while 3`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; pauses while 4`] = `""`; - -exports[`debugger; statement basic test 1`] = ` -Object { - "head": Object { - "a": 2, - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement basic test 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement basic test 3`] = `""`; - -exports[`debugger; statement execution sequence 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement execution sequence 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement execution sequence 3`] = `""`; - -exports[`debugger; statement hoisting 1`] = ` -Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - "c": Symbol(Used to implement hoisting), - "z": Symbol(Used to implement hoisting), - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement hoisting 2`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 10, - }, - ], - "callee": Node { - "end": 108, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 9, - }, - "start": Position { - "column": 2, - "line": 9, - }, - }, - "name": "a", - "start": 107, - "type": "Identifier", - }, - "end": 112, - "loc": SourceLocation { - "end": Position { - "column": 7, - "line": 9, - }, - "start": Position { - "column": 2, - "line": 9, - }, - }, - "start": 107, - "type": "CallExpression", - }, - "head": Object { - "x": 10, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement hoisting 3`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement hoisting 4`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement hoisting 5`] = `""`; - -exports[`debugger; statement in function 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 10, - }, - ], - "callee": Node { - "end": 53, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 6, - }, - "start": Position { - "column": 2, - "line": 6, - }, - }, - "name": "a", - "start": 52, - "type": "Identifier", - }, - "end": 57, - "loc": SourceLocation { - "end": Position { - "column": 7, - "line": 6, - }, - "start": Position { - "column": 2, - "line": 6, - }, - }, - "start": 52, - "type": "CallExpression", - }, - "head": Object { - "x": 10, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement in function 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement in function 3`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement in function 4`] = `""`; - -exports[`debugger; statement test function scope 1`] = ` -Object { - "head": Object { - "b": 100, - "c": 200, - "d": 300, - "e": 30000, - "f": 60000, - "g": 2000, - "h": 2300, - "i": 666.6666666666666, - "j": 600, - "k": 0.0033333333333333335, - "l": 0.5, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement test function scope 2`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 10, - }, - ], - "callee": Node { - "end": 266, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 17, - }, - "start": Position { - "column": 2, - "line": 17, - }, - }, - "name": "a", - "start": 265, - "type": "Identifier", - }, - "end": 270, - "loc": SourceLocation { - "end": Position { - "column": 7, - "line": 17, - }, - "start": Position { - "column": 2, - "line": 17, - }, - }, - "start": 265, - "type": "CallExpression", - }, - "head": Object { - "x": 10, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`debugger; statement test function scope 3`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement test function scope 4`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`debugger; statement test function scope 5`] = `""`; - -exports[`setBreakpointAtLine basic 1`] = ` -Object { - "head": Object { - "a": Symbol(Used to implement hoisting), - "b": Symbol(Used to implement hoisting), - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine basic 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine basic 3`] = `""`; - -exports[`setBreakpointAtLine for loops 1`] = ` -Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 2`] = ` -Object { - "head": Object { - "i": 1, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 3`] = ` -Object { - "head": Object { - "_copy_of_i": 1, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 4`] = ` -Object { - "head": Object { - "i": 1, - }, - "id": Any, - "name": "blockEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 5`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine for loops 6`] = `""`; - -exports[`setBreakpointAtLine for loops 7`] = ` -Array [ - Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - }, - "id": "95", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 2, - }, - "id": "94", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "_copy_of_i": 2, - }, - "id": "93", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 2, - }, - "id": "89", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "87", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine for loops 8`] = `""`; - -exports[`setBreakpointAtLine for loops 9`] = ` -Array [ - Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - }, - "id": "98", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 4, - }, - "id": "97", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "_copy_of_i": 4, - }, - "id": "96", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 4, - }, - "id": "89", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "87", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine for loops 10`] = `""`; - -exports[`setBreakpointAtLine for loops 11`] = ` -Array [ - Object { - "head": Object { - "b": Symbol(Used to implement hoisting), - }, - "id": "101", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 8, - }, - "id": "100", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "_copy_of_i": 8, - }, - "id": "99", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "i": 8, - }, - "id": "89", - "name": "blockEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "87", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine for loops 12`] = `""`; - -exports[`setBreakpointAtLine for loops 13`] = ` -Array [ - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "87", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine for loops 14`] = `""`; - -exports[`setBreakpointAtLine function 1 1`] = ` -Object { - "head": Object { - "a": Symbol(Used to implement hoisting), - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 1 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 1 3`] = `""`; - -exports[`setBreakpointAtLine function 2 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": "bob", - }, - ], - "callee": Node { - "end": 43, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 5, - }, - "start": Position { - "column": 2, - "line": 5, - }, - }, - "name": "a", - "start": 42, - "type": "Identifier", - }, - "end": 50, - "loc": SourceLocation { - "end": Position { - "column": 10, - "line": 5, - }, - "start": Position { - "column": 2, - "line": 5, - }, - }, - "start": 42, - "type": "CallExpression", - }, - "head": Object { - "x": "bob", - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 2 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 2 3`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 2 4`] = `""`; - -exports[`setBreakpointAtLine function 3 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 3 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 3 3`] = `""`; - -exports[`setBreakpointAtLine function 4 1`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 4 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine function 4 3`] = `""`; - -exports[`setBreakpointAtLine granularity 1 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 1, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 81, - "loc": SourceLocation { - "end": Position { - "column": 6, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 1, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 1 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 1 3`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 1 4`] = `""`; - -exports[`setBreakpointAtLine granularity 1 5`] = ` -Array [ - Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": -1, - }, - ], - "callee": Node { - "end": 58, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "name": "a", - "start": 57, - "type": "Identifier", - }, - "end": 69, - "loc": SourceLocation { - "end": Position { - "column": 16, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "start": 57, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": -1, - }, - "id": "62", - "name": "a", - "tail": null, - }, - Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 0, - }, - ], - "callee": Node { - "end": 58, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "name": "a", - "start": 57, - "type": "Identifier", - }, - "end": 69, - "loc": SourceLocation { - "end": Position { - "column": 16, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "start": 57, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 0, - }, - "id": "59", - "name": "a", - "tail": null, - }, - Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 1, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 81, - "loc": SourceLocation { - "end": Position { - "column": 6, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 1, - }, - "id": "56", - "name": "a", - "tail": null, - }, - Object { - "head": Object { - "a": [Function], - }, - "id": "55", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "54", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine granularity 1 6`] = `""`; - -exports[`setBreakpointAtLine granularity 2 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": -1, - }, - ], - "callee": Node { - "end": 58, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "name": "a", - "start": 57, - "type": "Identifier", - }, - "end": 69, - "loc": SourceLocation { - "end": Position { - "column": 16, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "start": 57, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": -1, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 2`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 0, - }, - ], - "callee": Node { - "end": 58, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "name": "a", - "start": 57, - "type": "Identifier", - }, - "end": 69, - "loc": SourceLocation { - "end": Position { - "column": 16, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "start": 57, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 0, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 3`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 1, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 81, - "loc": SourceLocation { - "end": Position { - "column": 6, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 1, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 4`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 5`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 2 6`] = `""`; - -exports[`setBreakpointAtLine granularity 2 7`] = ` -Array [ - Object { - "head": Object { - "a": [Function], - }, - "id": "66", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "65", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine granularity 2 8`] = `""`; - -exports[`setBreakpointAtLine granularity 3 1`] = ` -Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 1, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 81, - "loc": SourceLocation { - "end": Position { - "column": 6, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 1, - }, - "id": Any, - "name": "a", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 3 2`] = ` -Object { - "head": Object { - "a": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 3 3`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine granularity 3 4`] = `""`; - -exports[`setBreakpointAtLine granularity 3 5`] = ` -Array [ - Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 0, - }, - ], - "callee": Node { - "end": 58, - "loc": SourceLocation { - "end": Position { - "column": 5, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "name": "a", - "start": 57, - "type": "Identifier", - }, - "end": 69, - "loc": SourceLocation { - "end": Position { - "column": 16, - "line": 5, - }, - "start": Position { - "column": 4, - "line": 5, - }, - }, - "start": 57, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 0, - }, - "id": "81", - "name": "a", - "tail": null, - }, - Object { - "callExpression": Object { - "arguments": Array [ - Object { - "loc": undefined, - "type": "Literal", - "value": 1, - }, - ], - "callee": Node { - "end": 78, - "loc": SourceLocation { - "end": Position { - "column": 3, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "name": "a", - "start": 77, - "type": "Identifier", - }, - "end": 81, - "loc": SourceLocation { - "end": Position { - "column": 6, - "line": 7, - }, - "start": Position { - "column": 2, - "line": 7, - }, - }, - "start": 77, - "type": "CallExpression", - }, - "head": Object { - "ctrlf": 1, - }, - "id": "78", - "name": "a", - "tail": null, - }, - Object { - "head": Object { - "a": [Function], - }, - "id": "77", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "76", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine granularity 3 6`] = `""`; - -exports[`setBreakpointAtLine granularity 3 7`] = ` -Array [ - Object { - "head": Object { - "a": [Function], - }, - "id": "77", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "76", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine granularity 3 8`] = `""`; - -exports[`setBreakpointAtLine while loops 1`] = ` -Object { - "head": Object { - "a": 9, - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine while loops 2`] = ` -Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": Any, - "name": "programEnvironment", - "tail": null, -} -`; - -exports[`setBreakpointAtLine while loops 3`] = `""`; - -exports[`setBreakpointAtLine while loops 4`] = ` -Array [ - Object { - "head": Object { - "a": 6, - }, - "id": "103", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "102", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine while loops 5`] = `""`; - -exports[`setBreakpointAtLine while loops 6`] = ` -Array [ - Object { - "head": Object { - "a": 3, - }, - "id": "103", - "name": "programEnvironment", - "tail": null, - }, - Object { - "head": Object { - "$accumulate": [Function], - "$append": [Function], - "$build_list": [Function], - "$enum_list": [Function], - "$filter": [Function], - "$length": [Function], - "$list_to_string": [Function], - "$map": [Function], - "$remove": [Function], - "$remove_all": [Function], - "$reverse": [Function], - "__access_export__": [Function], - "__access_named_export__": [Function], - "accumulate": [Function], - "append": [Function], - "build_list": [Function], - "build_stream": [Function], - "enum_list": [Function], - "enum_stream": [Function], - "equal": [Function], - "eval_stream": [Function], - "filter": [Function], - "for_each": [Function], - "integers_from": [Function], - "is_stream": [Function], - "length": [Function], - "list_ref": [Function], - "list_to_stream": [Function], - "list_to_string": [Function], - "map": [Function], - "member": [Function], - "remove": [Function], - "remove_all": [Function], - "reverse": [Function], - "stream_append": [Function], - "stream_filter": [Function], - "stream_for_each": [Function], - "stream_length": [Function], - "stream_map": [Function], - "stream_member": [Function], - "stream_ref": [Function], - "stream_remove": [Function], - "stream_remove_all": [Function], - "stream_reverse": [Function], - "stream_to_list": [Function], - }, - "id": "102", - "name": "programEnvironment", - "tail": null, - }, -] -`; - -exports[`setBreakpointAtLine while loops 7`] = `""`; diff --git a/src/__tests__/__snapshots__/return-regressions.ts.snap b/src/__tests__/__snapshots__/return-regressions.ts.snap deleted file mode 100644 index 4a6940382..000000000 --- a/src/__tests__/__snapshots__/return-regressions.ts.snap +++ /dev/null @@ -1,359 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Bare early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return i+1; - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - if (true) { - return 1; - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - while (true) { - return 1; - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - return 1; - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Calling unreachable results in error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - unreachable(); - return 0; - } - f(); - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Expected number on right hand side of operation, got boolean.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return id(i+1) + id(i+2); - } - return 0; - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - if (true) { - return id(1) + id(2); - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - while (true) { - return id(1) + id(2); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - return id(1) + id(2); - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return id(i+1); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - if (true) { - return id(1); - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - while (true) { - return id(1); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - return id(1); - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/stdlib.ts.snap b/src/__tests__/__snapshots__/stdlib.ts.snap index 6bfca218b..2efb0a3ad 100644 --- a/src/__tests__/__snapshots__/stdlib.ts.snap +++ b/src/__tests__/__snapshots__/stdlib.ts.snap @@ -1,829 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Builtins work as expected 0: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display('message');", - "displayResult": Array [ - "\\"message\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "message", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 1 1`] = `"Line 1: Error: \\"error!\\""`; -exports[`Builtins work as expected 1: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "error('error!');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: \\"error!\\"", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 56 1`] = `"Line 1: Error: head(xs) expects a pair as argument xs, but encountered null"`; -exports[`Builtins work as expected 2: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_undefined(undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 57 1`] = `"Line 1: Error: tail(xs) expects a pair as argument xs, but encountered null"`; -exports[`Builtins work as expected 3: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_undefined(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 58 1`] = `"Line 1: Error: head(xs) expects a pair as argument xs, but encountered 1"`; -exports[`Builtins work as expected 4: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_null(undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 59 1`] = `"Line 1: Error: tail(xs) expects a pair as argument xs, but encountered 1"`; -exports[`Builtins work as expected 5: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_null(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 6: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 7: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 8: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 9: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 10: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 11: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 12: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 13: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 14: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 15: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 16: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 17: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 18: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 19: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 20: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 21: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(display);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 22: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(x => x);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 23: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -is_function(f);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 24: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 25: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 26: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 27: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array([1]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 28: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 29: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 30: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object([1]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 31: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object({});", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 32: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object({a: 1});", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 33: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(x => x);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 34: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(display);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 35: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 36: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 37: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_object(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 38: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_NaN(1 / 0);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 39: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_NaN(NaN);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 40: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_NaN(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 41: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_NaN(x => x);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 42: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "has_own_property({a: 1, b: 2}, 'a');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 43: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "has_own_property({a: 1, b: 2}, 'c');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 44: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "array_length([1]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 45: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 10);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 46: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 47: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(get_time());", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 48: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const start = get_time(); -function repeatUntilDifferentTime() { - if (start === get_time()) { - return repeatUntilDifferentTime(); - } else { - return true; - } -} -repeatUntilDifferentTime();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 49: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "pair(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - 2, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 50: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - 2, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 51: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 52: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 53: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(list(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 54: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "head(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 55: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 56: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "head(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 57: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: tail(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 58: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "head(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: head(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 59: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: tail(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 60: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "length(list(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 61: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "length(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 33: Error: tail(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 61 1`] = `"Line 33: Error: tail(xs) expects a pair as argument xs, but encountered 1"`; diff --git a/src/__tests__/__snapshots__/stringify.ts.snap b/src/__tests__/__snapshots__/stringify.ts.snap deleted file mode 100644 index 609e54290..000000000 --- a/src/__tests__/__snapshots__/stringify.ts.snap +++ /dev/null @@ -1,543 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Correctly handles circular structures with multiple entry points: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = enum_list(1, 3); -set_tail(tail(tail(x)), x); -stringify(list(x, tail(x), tail(tail(x))));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[ [1, [2, [3, ...]]], -[[2, [3, [1, ...]]], [[3, [1, [2, ...]]], null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of arrays are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = [1, 'true', true, () => 1]; -stringify(xs);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[1, \\"true\\", true, () => 1]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of arrow functions are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => x; -stringify(f);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "(x, y) => x", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of big objects are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = { a: 1, b: true, c: () => 1, d: { e: 5, f: 6 }, g: 0, h: 0, i: 0, j: 0, k: 0, l: 0, m: 0, n: 0}; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "{ \\"a\\": 1, - \\"b\\": true, - \\"c\\": () => 1, - \\"d\\": {\\"e\\": 5, \\"f\\": 6}, - \\"g\\": 0, - \\"h\\": 0, - \\"i\\": 0, - \\"j\\": 0, - \\"k\\": 0, - \\"l\\": 0, - \\"m\\": 0, - \\"n\\": 0}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of booleans are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "\\"true\\"", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of builtins are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(pair);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "function pair(left, right) { - [implementation hidden] -}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of empty arrays are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = []; -stringify(xs);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of functions are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x; -} -stringify(f);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "function f(x, y) { - return x; -}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of huge arrays are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const arr = []; -for (let i = 0; i < 100; i = i + 1) { - arr[i] = i; -} -stringify(arr);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[ 0, - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26, - 27, - 28, - 29, - 30, - 31, - 32, - 33, - 34, - 35, - 36, - 37, - 38, - 39, - 40, - 41, - 42, - 43, - 44, - 45, - 46, - 47, - 48, - 49, - 50, - 51, - 52, - 53, - 54, - 55, - 56, - 57, - 58, - 59, - 60, - 61, - 62, - 63, - 64, - 65, - 66, - 67, - 68, - 69, - 70, - 71, - 72, - 73, - 74, - 75, - 76, - 77, - 78, - 79, - 80, - 81, - 82, - 83, - 84, - 85, - 86, - 87, - 88, - 89, - 90, - 91, - 92, - 93, - 94, - 95, - 96, - 97, - 98, - 99]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of huge lists are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(enum_list(1, 100));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[ 1, -[ 2, -[ 3, -[ 4, -[ 5, -[ 6, -[ 7, -[ 8, -[ 9, -[ 10, -[ 11, -[ 12, -[ 13, -[ 14, -[ 15, -[ 16, -[ 17, -[ 18, -[ 19, -[ 20, -[ 21, -[ 22, -[ 23, -[ 24, -[ 25, -[ 26, -[ 27, -[ 28, -[ 29, -[ 30, -[ 31, -[ 32, -[ 33, -[ 34, -[ 35, -[ 36, -[ 37, -[ 38, -[ 39, -[ 40, -[ 41, -[ 42, -[ 43, -[ 44, -[ 45, -[ 46, -[ 47, -[ 48, -[ 49, -[ 50, -[ 51, -[ 52, -[ 53, -[ 54, -[ 55, -[ 56, -[ 57, -[ 58, -[ 59, -[ 60, -[ 61, -[ 62, -[ 63, -[ 64, -[ 65, -[ 66, -[ 67, -[ 68, -[ 69, -[ 70, -[ 71, -[ 72, -[ 73, -[ 74, -[ 75, -[ 76, -[ 77, -[ 78, -[ 79, -[ 80, -[ 81, -[ 82, -[ 83, -[ 84, -[ 85, -[ 86, -[ 87, -[ 88, -[89, [90, [91, [92, [93, [94, [95, [96, [97, [98, [99, [100, null]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of lists are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(enum_list(1, 10));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[1, [2, [3, [4, [5, [6, [7, [8, [9, [10, null]]]]]]]]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of multidimensional arrays are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = [1, 'true', [true, () => 1, [[]]]]; -stringify(xs);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[1, \\"true\\", [true, () => 1, [[]]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of nested objects are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = { a: 1, b: true, c: () => 1, d: { e: 5, f: 6 } }; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "{\\"a\\": 1, \\"b\\": true, \\"c\\": () => 1, \\"d\\": {\\"e\\": 5, \\"f\\": 6}}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of nested objects are nice: expectResult 2`] = ` -Object { - "alertResult": Array [], - "code": "let o = {}; -o.o = o; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "{\\"o\\": ...}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of null is nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "null", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of numbers are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(0);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "0", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of objects are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = { a: 1, b: true, c: () => 1 }; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "{\\"a\\": 1, \\"b\\": true, \\"c\\": () => 1}", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of objects with toReplString member calls toReplString: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const o = { toReplString: () => '' }; -stringify(o);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of strings are nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify('a string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "\\"a string\\"", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation of undefined is nice: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "undefined", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation with 1 space indent: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse('x=>x;'), 1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[\\"lambda_expression\\", -[[[\\"name\\", [\\"x\\", null]], null], -[[\\"return_statement\\", [[\\"name\\", [\\"x\\", null]], null]], null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation with default (2 space) indent: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse('x=>x;'));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[ \\"lambda_expression\\", -[ [[\\"name\\", [\\"x\\", null]], null], -[[\\"return_statement\\", [[\\"name\\", [\\"x\\", null]], null]], null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation with more than 10 space indent should trim to 10 space indent: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse('x=>x;'), 100);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[ \\"lambda_expression\\", -[ [[\\"name\\", [\\"x\\", null]], null], -[[\\"return_statement\\", [[\\"name\\", [\\"x\\", null]], null]], null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`String representation with no indent: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse('x=>x;'), 0);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[\\"lambda_expression\\", -[[[\\"name\\", [\\"x\\", null]], null], -[[\\"return_statement\\", [[\\"name\\", [\\"x\\", null]], null]], null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/__snapshots__/tailcall-return.ts.snap b/src/__tests__/__snapshots__/tailcall-return.ts.snap deleted file mode 100644 index 2ebb65935..000000000 --- a/src/__tests__/__snapshots__/tailcall-return.ts.snap +++ /dev/null @@ -1,169 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Simple tail call returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in boolean operators work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return false || f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in conditional expressions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x <= 0 ? y : f(x-1, y+1); -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in nested mix of conditional expressions boolean operators work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x <= 0 ? y : false || x > 0 ? f(x-1, y+1) : 'unreachable'; -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in arrow block functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -}; -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in arrow functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => x <= 0 ? y : f(x-1, y+1); -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mixed tail-call/non-tail-call recursion work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y, z) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+f(0, z, 0), z); - } -} -f(5000, 5000, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 15000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mutual recursion with arrow functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => x <= 0 ? y : g(x-1, y+1); -const g = (x, y) => x <= 0 ? y : f(x-1, y+1); -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mutual recursion work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return g(x-1, y+1); - } -} -function g(x, y) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/__tests__/block-scoping.ts b/src/__tests__/block-scoping.ts index d7de4b3fb..9066b8128 100644 --- a/src/__tests__/block-scoping.ts +++ b/src/__tests__/block-scoping.ts @@ -14,8 +14,7 @@ test('standalone block statements', () => { return x; } test(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`true`) }) @@ -33,8 +32,7 @@ test('const uses block scoping instead of function scoping', () => { return x; } test(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`true`) }) @@ -53,7 +51,7 @@ test('let uses block scoping instead of function scoping', () => { } test(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -69,7 +67,7 @@ test('for loops use block scoping instead of function scoping', () => { } test(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -87,7 +85,7 @@ test('while loops use block scoping instead of function scoping', () => { } test(); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(`true`) }) @@ -105,7 +103,7 @@ test('for loop `let` variables are copied into the block scope', () => { } test(); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(`1`) }) @@ -134,9 +132,7 @@ test('No hoisting of functions. Only the name is hoisted like let and const', () return 1; } v; - `).toMatchInlineSnapshot( - `"Line 1: Name f declared later in current scope but not yet assigned"` - ) + `).toMatchInlineSnapshot(`"Line 1: ReferenceError: Cannot access 'f' before initialization"`) }, 30000) test('Error when accessing temporal dead zone', () => { @@ -147,9 +143,7 @@ test('Error when accessing temporal dead zone', () => { const a = 5; } f(); - `).toMatchInlineSnapshot( - `"Line 3: Name a declared later in current scope but not yet assigned"` - ) + `).toMatchInlineSnapshot(`"Line 3: ReferenceError: Cannot access 'a' before initialization"`) }, 30000) // tslint:disable-next-line:max-line-length @@ -160,9 +154,7 @@ test('In a block, every going-to-be-defined variable in the block cannot be acce a + a; const a = 10; } - `).toMatchInlineSnapshot( - `"Line 3: Name a declared later in current scope but not yet assigned"` - ) + `).toMatchInlineSnapshot(`"Line 3: ReferenceError: Cannot access 'a' before initialization"`) }, 30000) test('Shadowed variables may not be assigned to until declared in the current scope', () => { @@ -177,5 +169,7 @@ test('Shadowed variables may not be assigned to until declared in the current sc test(); `, { chapter: Chapter.SOURCE_3 } - ).toMatchInlineSnapshot(`"Line 3: Name variable not declared."`) + ).toMatchInlineSnapshot( + `"Line 3: ReferenceError: Cannot access 'variable' before initialization"` + ) }) diff --git a/src/__tests__/display.ts b/src/__tests__/display.ts index a3d053abf..3626f8d75 100644 --- a/src/__tests__/display.ts +++ b/src/__tests__/display.ts @@ -8,88 +8,55 @@ test('display throw error if second argument is non-string when used', () => { }) test('display second argument can be a string', () => { - return expectDisplayResult(`display(31072020, "my_first_String");`, { native: true }) - .toMatchInlineSnapshot(` - Array [ - "my_first_String 31072020", - ] - `) + return expectDisplayResult(`display(31072020, "my_first_String");`).toMatchInlineSnapshot( + `Array []` + ) }) test('display can be used to display numbers', () => { - return expectDisplayResult(`display(0);`, { native: true }).toMatchInlineSnapshot(` -Array [ - "0", -] -`) + return expectDisplayResult(`display(0);`).toMatchInlineSnapshot(`Array []`) }) test('display can be used to display funny numbers', () => { - return expectDisplayResult(`display(1e38); display(NaN); display(Infinity);`, { native: true }) - .toMatchInlineSnapshot(` -Array [ - "1e+38", - "NaN", - "Infinity", -] -`) + return expectDisplayResult( + `display(1e38); display(NaN); display(Infinity);` + ).toMatchInlineSnapshot(`Array []`) }) test('display can be used to display (escaped) strings', () => { - return expectDisplayResult(`display("Tom's assisstant said: \\"tuna.\\"");`, { native: true }) - .toMatchInlineSnapshot(` -Array [ - "\\"Tom's assisstant said: \\\\\\"tuna.\\\\\\"\\"", -] -`) + return expectDisplayResult( + `display("Tom's assisstant said: \\"tuna.\\"");` + ).toMatchInlineSnapshot(`Array []`) }) test('raw_display can be used to display (unescaped) strings directly', () => { - return expectDisplayResult(`raw_display("Tom's assisstant said: \\"tuna.\\"");`, { native: true }) - .toMatchInlineSnapshot(` -Array [ - "Tom's assisstant said: \\"tuna.\\"", -] -`) + return expectDisplayResult( + `raw_display("Tom's assisstant said: \\"tuna.\\"");` + ).toMatchInlineSnapshot(`Array []`) }) test('display can be used to display functions', () => { - return expectDisplayResult(`display(x => x); display((x, y) => x + y);`).toMatchInlineSnapshot(` -Array [ - "x => x", - "(x, y) => x + y", -] -`) + return expectDisplayResult(`display(x => x); display((x, y) => x + y);`).toMatchInlineSnapshot( + `Array []` + ) }) test('display can be used to display lists', () => { - return expectDisplayResult(`display(list(1, 2));`, { chapter: Chapter.SOURCE_2, native: true }) - .toMatchInlineSnapshot(` -Array [ - "[1, [2, null]]", -] -`) + return expectDisplayResult(`display(list(1, 2));`, Chapter.SOURCE_2).toMatchInlineSnapshot( + `Array []` + ) }) test('display can be used to display arrays', () => { return expectDisplayResult(`display([1, 2, [4, 5]]);`, { - chapter: Chapter.SOURCE_3, - native: true - }).toMatchInlineSnapshot(` -Array [ - "[1, 2, [4, 5]]", -] -`) + chapter: Chapter.SOURCE_3 + }).toMatchInlineSnapshot(`Array []`) }) test('display can be used to display objects', () => { return expectDisplayResult(`display({a: 1, b: 2, c: {d: 3}});`, { chapter: Chapter.LIBRARY_PARSER - }).toMatchInlineSnapshot(` -Array [ - "{\\"a\\": 1, \\"b\\": 2, \\"c\\": {\\"d\\": 3}}", -] -`) + }).toMatchInlineSnapshot(`Array []`) }) test('display with no arguments throws an error', () => { diff --git a/src/__tests__/environment.ts b/src/__tests__/environment.ts index e6b8b7b7a..623f3379e 100644 --- a/src/__tests__/environment.ts +++ b/src/__tests__/environment.ts @@ -1,10 +1,11 @@ import { Program } from 'estree' -import { evaluateProgram as evaluate } from '../interpreter/interpreter' -import { mockContext } from '../mocks/context' +import { mockContext } from '../utils/testing/mocks' import { parse } from '../parser/parser' import { Chapter } from '../types' import { stripIndent } from '../utils/formatters' +import { evaluate } from '../cse-machine/interpreter' +import { DEFAULT_SOURCE_OPTIONS } from '../runner' test('Function params and body identifiers are in different environment', () => { const code = stripIndent` @@ -18,7 +19,7 @@ test('Function params and body identifiers are in different environment', () => const context = mockContext(Chapter.SOURCE_4) context.prelude = null // hide the unneeded prelude const parsed = parse(code, context) - const it = evaluate(parsed as any as Program, context) + const it = evaluate(parsed as any as Program, context, DEFAULT_SOURCE_OPTIONS) const stepsToComment = 13 // manually counted magic number for (let i = 0; i < stepsToComment; i += 1) { it.next() diff --git a/src/__tests__/environmentTree.ts b/src/__tests__/environmentTree.ts index fa9e84a8a..7ef466d4f 100644 --- a/src/__tests__/environmentTree.ts +++ b/src/__tests__/environmentTree.ts @@ -1,6 +1,6 @@ import { createGlobalEnvironment, EnvTree, EnvTreeNode } from '../createContext' -import { pushEnvironment } from '../interpreter/interpreter' -import { mockContext, mockEnvironment } from '../mocks/context' +import { pushEnvironment } from '../cse-machine/utils' +import { mockContext, mockEnvironment } from '../utils/testing/mocks' import { Chapter } from '../types' test('EnvTree root should be null upon instantiation', () => { diff --git a/src/__tests__/index.ts b/src/__tests__/index.ts index bb6123e99..6003fce26 100644 --- a/src/__tests__/index.ts +++ b/src/__tests__/index.ts @@ -1,18 +1,16 @@ import { Position } from 'acorn/dist/acorn' import { SourceLocation } from 'estree' -import { findDeclaration, getScope } from '../index' +import { findDeclaration, getScope, runInContext } from '../index' import { Chapter, Value } from '../types' import { stripIndent } from '../utils/formatters' +import { createTestContext, expectParsedError, expectResult, testSuccess } from '../utils/testing' +import { TestOptions } from '../utils/testing/types' import { - createTestContext, - expectParsedError, - expectParsedErrorNoErrorSnapshot, - expectParsedErrorNoSnapshot, - expectResult, - expectToLooselyMatchJS, - expectToMatchJS -} from '../utils/testing' + evalWithBuiltins, + expectFinishedResultValue, + processTestOptions +} from '../utils/testing/misc' const toString = (x: Value) => '' + x @@ -46,8 +44,7 @@ test('Arrow function definition returns itself', () => { }) test('Builtins hide their implementation when stringify', () => { - return expectResult('stringify(pair);', { chapter: Chapter.SOURCE_2, native: true }) - .toMatchInlineSnapshot(` + return expectResult('stringify(pair);', { chapter: Chapter.SOURCE_2 }).toMatchInlineSnapshot(` "function pair(left, right) { [implementation hidden] }" @@ -57,7 +54,6 @@ test('Builtins hide their implementation when stringify', () => { test('Builtins hide their implementation when toString', () => { return expectResult('toString(pair);', { chapter: Chapter.SOURCE_2, - native: true, testBuiltins: { toString } }).toMatchInlineSnapshot(` "function pair(left, right) { @@ -66,46 +62,18 @@ test('Builtins hide their implementation when toString', () => { `) }) -test('Objects toString matches up with JS', () => { - return expectToMatchJS('toString({a: 1});', { - chapter: Chapter.LIBRARY_PARSER, - native: true, - testBuiltins: { toString } - }) -}) - -test('Arrays toString matches up with JS', () => { - return expectToMatchJS('toString([1, 2]);', { - chapter: Chapter.SOURCE_3, - native: true, - testBuiltins: { toString } - }) -}) - -test('functions toString (mostly) matches up with JS', () => { - return expectToLooselyMatchJS( - stripIndent` - function f(x) { +test('functions toString (mostly) matches up with JS', async () => { + const code = stripIndent` + function f(x) { return 5; } toString(a=>a) + toString(f); - `, - { native: true, testBuiltins: { toString } } - ) -}) + ` + const options: TestOptions = { testBuiltins: { toString } } + const { result } = await testSuccess(code, options) -test('primitives toString matches up with JS', () => { - return expectToMatchJS( - stripIndent` - toString(true) + - toString(false) + - toString(1) + - toString(1.5) + - toString(null) + - toString(undefined) + - toString(NaN); - `, - { chapter: Chapter.SOURCE_2, native: true, testBuiltins: { toString } } + expect(result.value.replace(/ /g, '')).toEqual( + evalWithBuiltins(code, options.testBuiltins).replace(/ /g, '') ) }) @@ -114,8 +82,7 @@ test('Factorial arrow function', () => { stripIndent` const fac = (i) => i === 1 ? 1 : i * fac(i-1); fac(5); - `, - { native: true } + ` ).toBe(120) }) @@ -132,24 +99,15 @@ test('parseError for template literals with expressions', () => { }) test('Simple arrow function infinite recursion represents CallExpression well', () => { - return expectParsedErrorNoErrorSnapshot('(x => x(x)(x))(x => x(x)(x));').toMatchInlineSnapshot(` - "Line 1: Maximum call stack size exceeded - x(x => x(x)(x)).. x(x => x(x)(x)).. x(x => x(x)(x)).." - `) + return expectParsedError('(x => x(x)(x))(x => x(x)(x));').toMatchInlineSnapshot( + `"Line 1: RangeError: Maximum call stack size exceeded"` + ) }, 30000) test('Simple function infinite recursion represents CallExpression well', () => { - return expectParsedErrorNoErrorSnapshot('function f(x) {return x(x)(x);} f(f);') - .toMatchInlineSnapshot(` - "Line 1: Maximum call stack size exceeded - x(function f(x) { - return x(x)(x); - }).. x(function f(x) { - return x(x)(x); - }).. x(function f(x) { - return x(x)(x); - }).." - `) + return expectParsedError('function f(x) {return x(x)(x);} f(f);').toMatchInlineSnapshot( + `"RangeError: Maximum call stack size exceeded"` + ) }, 30000) test('Cannot overwrite consts even when assignment is allowed', () => { @@ -162,7 +120,7 @@ test('Cannot overwrite consts even when assignment is allowed', () => { } test(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"Line 3: Cannot assign new value to constant constant."`) }) @@ -174,7 +132,7 @@ test('Assignment has value', () => { b === 4 && a === 4; `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toBe(true) }) @@ -186,7 +144,7 @@ test('Array assignment has value', () => { const b = arr[1] = arr[2] = 4; arr[0] === 1 && arr[1] === 4 && arr[2] === 4; `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toBe(true) }) @@ -200,51 +158,46 @@ test('Can overwrite lets when assignment is allowed', () => { } test(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toBe(true) }) test('Arrow function infinite recursion with list args represents CallExpression well', () => { - return expectParsedErrorNoErrorSnapshot( + return expectParsedError( stripIndent` const f = xs => append(f(xs), list()); f(list(1, 2)); `, { chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(` - "Line 1: Maximum call stack size exceeded - f([1, [2, null]]).. f([1, [2, null]]).. f([1, [2, null]]).." - `) + ).toMatchInlineSnapshot( + `"Line 2: The function (anonymous) has encountered an infinite loop. It has no base case."` + ) }, 30000) test('Function infinite recursion with list args represents CallExpression well', () => { - return expectParsedErrorNoErrorSnapshot( + return expectParsedError( stripIndent` function f(xs) { return append(f(xs), list()); } f(list(1, 2)); - `, - { chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(` - "Line 1: Maximum call stack size exceeded - f([1, [2, null]]).. f([1, [2, null]]).. f([1, [2, null]]).." - `) + ` + ).toMatchInlineSnapshot(`"Line 1: Name append not declared."`) }, 30000) test('Arrow function infinite recursion with different args represents CallExpression well', () => { - return expectParsedErrorNoSnapshot(stripIndent` + return expectParsedError(stripIndent` const f = i => f(i+1) - 1; f(0); - `).toEqual( - expect.stringMatching(/^Line 1: Maximum call stack size exceeded\n\ *(f\(\d*\)[^f]{2,4}){3}/) + `).toMatchInlineSnapshot( + `"Line 2: The function (anonymous) has encountered an infinite loop. It has no base case."` ) }, 30000) test('Function infinite recursion with different args represents CallExpression well', () => { - return expectParsedErrorNoSnapshot(stripIndent` + return expectParsedError(stripIndent` function f(i) { return f(i+1) - 1; } f(0); - `).toEqual( - expect.stringMatching(/^Line 1: Maximum call stack size exceeded\n\ *(f\(\d*\)[^f]{2,4}){3}/) + `).toMatchInlineSnapshot( + `"Line 2: The function f has encountered an infinite loop. It has no base case."` ) }, 30000) @@ -256,7 +209,7 @@ test('Functions passed into non-source functions remain equal', () => { } identity(t) === t && t(1, 2, 3) === 6; `, - { chapter: Chapter.SOURCE_3, testBuiltins: { 'identity(x)': (x: any) => x }, native: true } + { chapter: Chapter.SOURCE_3, testBuiltins: { 'identity(x)': (x: any) => x } } ).toBe(true) }) @@ -266,7 +219,7 @@ test('Accessing array with nonexistent index returns undefined', () => { const a = []; a[1]; `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toBe(undefined) }) @@ -276,7 +229,7 @@ test('Accessing object with nonexistent property returns undefined', () => { const o = {}; o.nonexistent; `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toBe(undefined) }) @@ -287,7 +240,7 @@ test('Simple object assignment and retrieval', () => { o.a = 1; o.a; `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toBe(1) }) @@ -300,7 +253,7 @@ test('Deep object assignment and retrieval', () => { o.a.b.c = "string"; o.a.b.c; `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toBe('string') }) @@ -309,7 +262,7 @@ test('Test apply_in_underlying_javascript', () => { stripIndent` apply_in_underlying_javascript((a, b, c) => a * b * c, list(2, 5, 6)); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toBe(60) }) @@ -318,7 +271,7 @@ test('Test equal for primitives', () => { stripIndent` equal(1, 1) && equal("str", "str") && equal(null, null) && !equal(1, 2) && !equal("str", ""); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toBe(true) }) @@ -327,7 +280,7 @@ test('Test equal for lists', () => { stripIndent` equal(list(1, 2), pair(1, pair(2, null))) && equal(list(1, 2, 3, 4), list(1, 2, 3, 4)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toBe(true) }) @@ -336,7 +289,7 @@ test('Test equal for different lists', () => { stripIndent` !equal(list(1, 2), pair(1, 2)) && !equal(list(1, 2, 3), list(1, list(2, 3))); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toBe(true) }) @@ -346,8 +299,7 @@ test('true if with empty if works', () => { if (true) { } else { } - `, - { native: true } + ` ).toBe(undefined) }) @@ -358,8 +310,7 @@ test('true if with nonempty if works', () => { 1; } else { } - `, - { native: true } + ` ).toBe(1) }) @@ -369,8 +320,7 @@ test('false if with empty else works', () => { if (false) { } else { } - `, - { native: true } + ` ).toBe(undefined) }) @@ -381,57 +331,105 @@ test('false if with nonempty if works', () => { } else { 2; } - `, - { native: true } + ` ).toBe(2) }) -test('test true conditional expression', () => { - return expectToMatchJS('true ? true : false;', { native: true }) -}) +describe('matchJSTests', () => { + async function expectToMatchJS(code: string, rawOptions: TestOptions = {}) { + const options = processTestOptions(rawOptions) + if (options.testBuiltins) { + options.testBuiltins = { + ...options.testBuiltins, + toString + } + } else { + options.testBuiltins = { toString } + } -test('test false conditional expression', () => { - return expectToMatchJS('false ? true : false;', { native: true }) -}) + const { result } = await testSuccess(code, options) -test('test false && true', () => { - return expectToMatchJS('false && true;', { native: true }) -}) + expect(evalWithBuiltins(code, options.testBuiltins)).toEqual(result.value) + } -test('test false && false', () => { - return expectToMatchJS('false && false;', { native: true }) -}) + test('primitives toString matches up with JS', async () => { + const code = stripIndent` + toString(true) + + toString(false) + + toString(1) + + toString(1.5) + + toString(null) + + toString(undefined) + + toString(NaN); + ` + + const options: TestOptions = { + testBuiltins: { toString }, + chapter: Chapter.SOURCE_2 + } + const { result } = await testSuccess(code, options) + expect(evalWithBuiltins(code, options.testBuiltins)).toEqual(result.value) + }) -test('test true && false', () => { - return expectToMatchJS('true && false;', { native: true }) -}) + test('test true conditional expression', () => { + return expectToMatchJS('true ? true : false;') + }) -test('test true && true', () => { - return expectToMatchJS('true && true;', { native: true }) -}) + test('test false conditional expression', () => { + return expectToMatchJS('false ? true : false;') + }) -test('test && shortcircuiting', () => { - return expectToMatchJS('false && 1();', { native: true }) -}) + test('test false && true', () => { + return expectToMatchJS('false && true;') + }) -test('test false || true', () => { - return expectToMatchJS('false || true;', { native: true }) -}) + test('test false && false', () => { + return expectToMatchJS('false && false;') + }) -test('test false || false', () => { - return expectToMatchJS('false || false;', { native: true }) -}) + test('test true && false', () => { + return expectToMatchJS('true && false;') + }) -test('test true || false', () => { - return expectToMatchJS('true || false;', { native: true }) -}) + test('test true && true', () => { + return expectToMatchJS('true && true;') + }) -test('test true || true', () => { - return expectToMatchJS('true || true;', { native: true }) -}) + test('test && shortcircuiting', () => { + return expectToMatchJS('false && 1();') + }) + + test('test false || true', () => { + return expectToMatchJS('false || true;') + }) + + test('test false || false', () => { + return expectToMatchJS('false || false;') + }) + + test('test true || false', () => { + return expectToMatchJS('true || false;') + }) + + test('test true || true', () => { + return expectToMatchJS('true || true;') + }) + + test('test || shortcircuiting', () => { + return expectToMatchJS('true || 1();') + }) + + test('Objects toString matches up with JS', () => { + return expectToMatchJS('toString({a: 1});', { + chapter: Chapter.LIBRARY_PARSER + }) + }) -test('test || shortcircuiting', () => { - return expectToMatchJS('true || 1();', { native: true }) + test('Arrays toString matches up with JS', () => { + return expectToMatchJS('toString([1, 2]);', { + chapter: Chapter.SOURCE_3 + }) + }) }) test('Rest parameters work', () => { @@ -447,7 +445,7 @@ test('Rest parameters work', () => { rest(1, 2); // no error rest(1, 2, ...[3, 4, 5], ...[6, 7], ...[]); `, - { native: true, chapter: Chapter.SOURCE_3 } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`28`) }) @@ -461,10 +459,18 @@ test('Test context reuse', async () => { } i; ` - await expectResult(init, { context, native: true }).toBe(0) - await expectResult('i = 100; f();', { context, native: true }).toBe(101) - await expectResult('f(); i;', { context, native: true }).toBe(102) - return expectResult('i;', { context, native: true }).toBe(102) + + const snippets: [string, any][] = [ + [init, 0], + ['i = 100; f();', 101], + ['f(); i;', 102], + ['i;', 102] + ] + + for (const [code, expected] of snippets) { + const result = await runInContext(code, context) + expectFinishedResultValue(result, expected) + } }) class SourceLocationTestResult { diff --git a/src/__tests__/inspect.ts b/src/__tests__/inspect.ts deleted file mode 100644 index 4a1eeffba..000000000 --- a/src/__tests__/inspect.ts +++ /dev/null @@ -1,483 +0,0 @@ -/* tslint:disable:max-line-length */ -import { parseError, resume, runInContext } from '../index' -import { mockContext } from '../mocks/context' -import { setBreakpointAtLine } from '../stdlib/inspector' -import { Chapter, Environment, Result } from '../types' - -// we need to tame the environments for snapshotting, -// so we remove the tail part that is a copy of the previous environment -// and we remove the first global environment -function flattenEnvironments(result: Result): Environment[] { - return (result as any) - .context!.runtime.environments.slice(0, -1) - .map((env: Environment) => ({ ...env, tail: null })) -} - -// Test suite skipped since functionality of debugger statements -// has been changed for environment visualiser. -xtest('debugger; statement basic test', () => { - const code1 = ` - let a = 2; - debugger; - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; statement in function', () => { - const code1 = ` - function a(x){ - debugger; - return x; - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; statement execution sequence', () => { - const code1 = ` - function a(x){ - return x; - debugger; - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; statement test function scope', () => { - const code1 = ` - function a(x){ - let b = 10 * x; - let c = 20 * x; - let d = 30 * x; - let e = d * b; - let f = c * d; - let g = 10 * c; - let h = g + d; - let i = g / 3; - let j = f / b; - let k = b / e; - let l = b / c; - debugger; - return x; - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; statement hoisting', () => { - const code1 = ` - function a(x){ - debugger; - let z = 20; - let c = z * x; - let b = 123095; - return x; - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; pauses for', () => { - const code1 = ` - function a(x){ - for (let i=0; i { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('debugger; pauses while', () => { - const code1 = ` - function a(x){ - while(x > 1){ - debugger; - x=x-1; - } - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -/* Breakpoints by line - * The frontend editor sets breakpoints through this, results might differ - * with debugger; statements. For all intents and purposes the correctness is: - * - whatever your little heart desires! - * - debugger; - * - setBreakpointAtLine - * So if anything goes wrong with this, default to your mental model or the - * behavior of the debugger; statement. - */ - -xtest('setBreakpointAtLine basic', () => { - const code1 = ` - const a = 10; - const b = 20; - ` - const context = mockContext(Chapter.SOURCE_3) - setBreakpointAtLine(['helloworld']) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('setBreakpointAtLine function 1', () => { - const code1 = ` - function a(x){ - return x + x; - } - a(10); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[1] = 'asd' - setBreakpointAtLine(breakline) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('setBreakpointAtLine function 2', () => { - const code1 = ` - function a(x){ - return x + x; - } - a("bob"); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[2] = 'asd' - setBreakpointAtLine(breakline) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('setBreakpointAtLine function 3', () => { - // this code will never break because the breakpoint is at a bracket which - // will never be evaluated. - const code1 = ` - function a(x){ - return x + x; - } - a(20); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[3] = 'asd' - setBreakpointAtLine(breakline) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('setBreakpointAtLine function 4', () => { - const code1 = ` - function a(x){ - return x + x; - } - a(123345898); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[4] = 'asd' - setBreakpointAtLine(breakline) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) -}) - -xtest('setBreakpointAtLine granularity 1', () => { - // this tests that we can indeed stop at individual lines - const code1 = ` - function a(ctrlf){ - return ctrlf < 0 ? - 0 : - a(ctrlf - 1); - } - a(1); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[2] = 'a' - setBreakpointAtLine(breakline) - // right now for some reason it breaks twice at the line. - // this should not happen - // if you do fix this issue, this is good to modify. - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj1) as Promise).then(obj2 => { - return (resume(obj2) as Promise).then(obj3 => { - expect(flattenEnvironments(obj3)).toMatchSnapshot() - expect(obj3.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - }) - }) - }) -}) - -xtest('setBreakpointAtLine granularity 2', () => { - // this tests that we can indeed stop at individual lines - const code1 = ` - function a(ctrlf){ - return ctrlf < 0 ? - 0 : - a(ctrlf - 1); - } - a(1); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[3] = 'a' - setBreakpointAtLine(breakline) - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj1) as Promise).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) - }) -}) - -xtest('setBreakpointAtLine granularity 3', () => { - // this tests that we can indeed stop at individual lines - const code1 = ` - function a(ctrlf){ - return ctrlf < 0 ? - 0 : - a(ctrlf - 1); - } - a(1); - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[4] = 'a' - setBreakpointAtLine(breakline) - // for some reason this is safe from the breaking twice problem - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj1) as Promise).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise).then(obj3 => { - expect(flattenEnvironments(obj3)).toMatchSnapshot() - expect(obj3.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) - }) - }) -}) - -xtest('setBreakpointAtLine for loops', () => { - // test stuff in loops work fine - const code1 = ` - for(let i=1;i<10;i=i*2) { - const b = i; - } - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[2] = '2' - setBreakpointAtLine(breakline) - // for some reason this is safe from the breaking twice problem - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj1) as Promise).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise).then(obj3 => { - expect(flattenEnvironments(obj3)).toMatchSnapshot() - expect(obj3.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj3) as Promise).then(obj4 => { - expect(flattenEnvironments(obj4)).toMatchSnapshot() - expect(obj4.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj4) as Promise).then(obj5 => { - expect(flattenEnvironments(obj5)).toMatchSnapshot() - expect(obj5.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) - }) - }) - }) - }) -}) - -xtest('setBreakpointAtLine while loops', () => { - // test stuff in loops work fine - const code1 = ` - let a = 9; - while (a > 3){ - a = a - 3; - } - ` - const context = mockContext(Chapter.SOURCE_3) - const breakline = [] - breakline[3] = '3' - setBreakpointAtLine(breakline) - // for some reason this is safe from the breaking twice problem - return runInContext(code1, context, { - scheduler: 'preemptive', - executionMethod: 'auto' - }).then(obj1 => { - flattenEnvironments(obj1).forEach(environment => { - expect(environment).toMatchSnapshot() - }) - expect(obj1.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj1) as Promise).then(obj2 => { - expect(flattenEnvironments(obj2)).toMatchSnapshot() - expect(obj2.status).toBe('suspended-cse-eval') - expect(parseError(context.errors)).toMatchSnapshot() - return (resume(obj2) as Promise).then(obj5 => { - expect(flattenEnvironments(obj5)).toMatchSnapshot() - expect(obj5.status).toBe('finished') - expect(parseError(context.errors)).toMatchSnapshot() - }) - }) - }) -}) diff --git a/src/__tests__/return-regressions.ts b/src/__tests__/return-regressions.ts index f690e5e74..587f7120d 100644 --- a/src/__tests__/return-regressions.ts +++ b/src/__tests__/return-regressions.ts @@ -36,8 +36,7 @@ test('Bare early returns work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`1`) }) @@ -58,8 +57,7 @@ test('Recursive call early returns work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`3`) }) @@ -80,8 +78,7 @@ test('Tail call early returns work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`1`) }) @@ -102,8 +99,7 @@ test('Bare early returns in if statements work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`1`) }) @@ -127,8 +123,7 @@ test('Recursive call early returns in if statements work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`3`) }) @@ -152,8 +147,7 @@ test('Tail call early returns in if statements work', () => { unreachable(); } f(); - `, - { native: true } + ` ).toMatchInlineSnapshot(`1`) }) @@ -175,7 +169,7 @@ test('Bare early returns in while loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + Chapter.SOURCE_3 ).toMatchInlineSnapshot(`1`) }) @@ -200,7 +194,7 @@ test('Recursive call early returns in while loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + Chapter.SOURCE_3 ).toMatchInlineSnapshot(`3`) }) @@ -225,7 +219,7 @@ test('Tail call early returns in while loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`1`) }) @@ -247,7 +241,7 @@ test('Bare early returns in for loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`1`) }) @@ -269,7 +263,7 @@ test('Recursive call early returns in for loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`3`) }) @@ -294,6 +288,6 @@ test('Tail call early returns in for loops work', () => { } f(); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`1`) }) diff --git a/src/__tests__/stdlib.ts b/src/__tests__/stdlib.ts index 9e77f2816..421a4bf25 100644 --- a/src/__tests__/stdlib.ts +++ b/src/__tests__/stdlib.ts @@ -615,11 +615,10 @@ test.each([ (chapter: Chapter, snippet: string, passing: boolean, returnValue: Value) => { if (passing) { return expectResult(stripIndent(snippet), { - chapter, - native: chapter !== Chapter.LIBRARY_PARSER + chapter }).toEqual(returnValue) } else { - return snapshotFailure(stripIndent(snippet), { chapter }, 'fails') + return snapshotFailure(stripIndent(snippet), { chapter }) } } ) diff --git a/src/__tests__/stringify-benchmark.ts b/src/__tests__/stringify-benchmark.ts index 485382f3e..113aefba2 100644 --- a/src/__tests__/stringify-benchmark.ts +++ b/src/__tests__/stringify-benchmark.ts @@ -31,7 +31,7 @@ test('stringify is fast', () => { const end = get_time(); end - start; `, - { chapter: Chapter.SOURCE_3, native: false } + { chapter: Chapter.SOURCE_3 } ).then(testResult => testResult.result) ).resolves.toBeLessThan(2000) // This benchmark takes 100ms on my machine, @@ -140,7 +140,6 @@ test('display_list with stringify is linear runtime', () => { `, { chapter: Chapter.SOURCE_3, - native: false, // we're measuring a builtin, no need for native testBuiltins: { no_display_list: noDisplayList } diff --git a/src/__tests__/stringify.ts b/src/__tests__/stringify.ts index 27b846b8b..29e6d8e26 100644 --- a/src/__tests__/stringify.ts +++ b/src/__tests__/stringify.ts @@ -12,8 +12,7 @@ test('String representation of numbers are nice', () => { return expectResult( stripIndent` stringify(0); - `, - { native: true } + ` ).toMatchInlineSnapshot(`"0"`) }) @@ -21,8 +20,7 @@ test('String representation of strings are nice', () => { return expectResult( stripIndent` stringify('a string'); - `, - { native: true } + ` ).toMatchInlineSnapshot(`"\\"a string\\""`) }) @@ -30,8 +28,7 @@ test('String representation of booleans are nice', () => { return expectResult( stripIndent` stringify('true'); - `, - { native: true } + ` ).toMatchInlineSnapshot(`"\\"true\\""`) }) @@ -42,8 +39,7 @@ test('String representation of functions are nice', () => { return x; } stringify(f); - `, - { native: true } + ` ).toMatchInlineSnapshot(` "function f(x, y) { return x; @@ -56,8 +52,7 @@ test('String representation of arrow functions are nice', () => { stripIndent` const f = (x, y) => x; stringify(f); - `, - { native: true } + ` ).toMatchInlineSnapshot(`"(x, y) => x"`) }) @@ -67,7 +62,7 @@ test('String representation of arrays are nice', () => { const xs = [1, 'true', true, () => 1]; stringify(xs); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"[1, \\"true\\", true, () => 1]"`) }) @@ -77,7 +72,7 @@ test('String representation of multidimensional arrays are nice', () => { const xs = [1, 'true', [true, () => 1, [[]]]]; stringify(xs); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"[1, \\"true\\", [true, () => 1, [[]]]]"`) }) @@ -87,7 +82,7 @@ test('String representation of empty arrays are nice', () => { const xs = []; stringify(xs); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"[]"`) }) @@ -96,7 +91,7 @@ test('String representation of lists are nice', () => { stripIndent` stringify(enum_list(1, 10)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`"[1, [2, [3, [4, [5, [6, [7, [8, [9, [10, null]]]]]]]]]]"`) }) @@ -107,7 +102,7 @@ test('Correctly handles circular structures with multiple entry points', () => { set_tail(tail(tail(x)), x); stringify(list(x, tail(x), tail(tail(x)))); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(` "[ [1, [2, [3, ...]]], [[2, [3, [1, ...]]], [[3, [1, [2, ...]]], null]]]" @@ -121,7 +116,7 @@ test('String representation of huge lists are nice', () => { stripIndent` stringify(enum_list(1, 100)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(` "[ 1, [ 2, @@ -225,7 +220,7 @@ test('String representation of huge arrays are nice', () => { } stringify(arr); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(` "[ 0, 1, @@ -336,7 +331,7 @@ test('String representation of objects are nice', () => { const o = { a: 1, b: true, c: () => 1 }; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`"{\\"a\\": 1, \\"b\\": true, \\"c\\": () => 1}"`) }) @@ -346,7 +341,7 @@ test('String representation of objects with toReplString member calls toReplStri const o = { toReplString: () => '' }; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`""`) }) @@ -356,7 +351,7 @@ test('String representation of nested objects are nice', () => { const o = { a: 1, b: true, c: () => 1, d: { e: 5, f: 6 } }; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot( `"{\\"a\\": 1, \\"b\\": true, \\"c\\": () => 1, \\"d\\": {\\"e\\": 5, \\"f\\": 6}}"` ) @@ -368,7 +363,7 @@ test('String representation of big objects are nice', () => { const o = { a: 1, b: true, c: () => 1, d: { e: 5, f: 6 }, g: 0, h: 0, i: 0, j: 0, k: 0, l: 0, m: 0, n: 0}; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(` "{ \\"a\\": 1, \\"b\\": true, @@ -392,7 +387,7 @@ test('String representation of nested objects are nice', () => { o.o = o; stringify(o); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`"{\\"o\\": ...}"`) }) @@ -432,7 +427,7 @@ test('String representation of builtins are nice', () => { stripIndent` stringify(pair); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(` "function pair(left, right) { [implementation hidden] @@ -445,7 +440,7 @@ test('String representation of null is nice', () => { stripIndent` stringify(null); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`"null"`) }) @@ -453,8 +448,7 @@ test('String representation of undefined is nice', () => { return expectResult( stripIndent` stringify(undefined); - `, - { native: true } + ` ).toMatchInlineSnapshot(`"undefined"`) }) @@ -464,7 +458,7 @@ test('String representation with no indent', () => { stripIndent` stringify(parse('x=>x;'), 0); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(` "[\\"lambda_expression\\", [[[\\"name\\", [\\"x\\", null]], null], @@ -477,7 +471,7 @@ test('String representation with 1 space indent', () => { stripIndent` stringify(parse('x=>x;'), 1); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(` "[\\"lambda_expression\\", [[[\\"name\\", [\\"x\\", null]], null], @@ -490,7 +484,7 @@ test('String representation with default (2 space) indent', () => { stripIndent` stringify(parse('x=>x;')); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(` "[ \\"lambda_expression\\", [ [[\\"name\\", [\\"x\\", null]], null], @@ -503,7 +497,7 @@ test('String representation with more than 10 space indent should trim to 10 spa stripIndent` stringify(parse('x=>x;'), 100); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ).toMatchInlineSnapshot(` "[ \\"lambda_expression\\", [ [[\\"name\\", [\\"x\\", null]], null], diff --git a/src/__tests__/tailcall-return.ts b/src/__tests__/tailcall-return.ts index 9a3a0ce27..7133595a8 100644 --- a/src/__tests__/tailcall-return.ts +++ b/src/__tests__/tailcall-return.ts @@ -1,8 +1,8 @@ import { stripIndent } from '../utils/formatters' -import { expectParsedErrorNoSnapshot, expectResult } from '../utils/testing' +import { expectParsedError, expectResult } from '../utils/testing' test('Check that stack is at most 10k in size', () => { - return expectParsedErrorNoSnapshot(stripIndent` + return expectParsedError(stripIndent` function f(x) { if (x <= 0) { return 0; @@ -11,7 +11,7 @@ test('Check that stack is at most 10k in size', () => { } } f(10000); - `).toEqual(expect.stringMatching(/Maximum call stack size exceeded\n([^f]*f){3}/)) + `).toMatchInlineSnapshot(`"Line 5: RangeError: Maximum call stack size exceeded"`) }, 10000) test('Simple tail call returns work', () => { @@ -25,8 +25,7 @@ test('Simple tail call returns work', () => { } } f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -37,8 +36,7 @@ test('Tail call in conditional expressions work', () => { return x <= 0 ? y : f(x-1, y+1); } f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -53,8 +51,7 @@ test('Tail call in boolean operators work', () => { } } f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -65,8 +62,7 @@ test('Tail call in nested mix of conditional expressions boolean operators work' return x <= 0 ? y : false || x > 0 ? f(x-1, y+1) : 'unreachable'; } f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -75,8 +71,7 @@ test('Tail calls in arrow functions work', () => { stripIndent` const f = (x, y) => x <= 0 ? y : f(x-1, y+1); f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -91,8 +86,7 @@ test('Tail calls in arrow block functions work', () => { } }; f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -114,8 +108,7 @@ test('Tail calls in mutual recursion work', () => { } } f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -125,8 +118,7 @@ test('Tail calls in mutual recursion with arrow functions work', () => { const f = (x, y) => x <= 0 ? y : g(x-1, y+1); const g = (x, y) => x <= 0 ? y : f(x-1, y+1); f(5000, 5000); - `, - { native: true } + ` ).toMatchInlineSnapshot(`10000`) }) @@ -141,7 +133,6 @@ test('Tail calls in mixed tail-call/non-tail-call recursion work', () => { } } f(5000, 5000, 2); - `, - { native: true } + ` ).toMatchInlineSnapshot(`15000`) }) diff --git a/src/alt-langs/__tests__/mapper.ts b/src/alt-langs/__tests__/mapper.ts index 8c4b8374b..6aaa97ea9 100644 --- a/src/alt-langs/__tests__/mapper.ts +++ b/src/alt-langs/__tests__/mapper.ts @@ -1,4 +1,4 @@ -import { mockContext } from "../../mocks/context"; +import { mockContext } from "../../utils/testing/mocks"; import { Chapter, Finished } from "../../types"; import { mapResult } from "../mapper"; diff --git a/src/alt-langs/scheme/__tests__/scheme-parser.ts b/src/alt-langs/scheme/__tests__/scheme-parser.ts index 89da8bbe5..a787f1ef7 100644 --- a/src/alt-langs/scheme/__tests__/scheme-parser.ts +++ b/src/alt-langs/scheme/__tests__/scheme-parser.ts @@ -1,5 +1,5 @@ import { parseError } from '../../..' -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import { Chapter } from '../../../types' import { SchemeParser } from '../../../parser/scheme' diff --git a/src/constants.ts b/src/constants.ts index 6b04dd92a..00d6e3ed5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -35,7 +35,6 @@ export const sourceLanguages: Language[] = [ { chapter: Chapter.SOURCE_2, variant: Variant.TYPED }, { chapter: Chapter.SOURCE_3, variant: Variant.DEFAULT }, { chapter: Chapter.SOURCE_3, variant: Variant.TYPED }, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT }, { chapter: Chapter.SOURCE_4, variant: Variant.DEFAULT }, { chapter: Chapter.SOURCE_4, variant: Variant.TYPED }, { chapter: Chapter.SOURCE_4, variant: Variant.EXPLICIT_CONTROL } diff --git a/src/createContext.ts b/src/createContext.ts index 705b70dcb..ac4a8ece0 100644 --- a/src/createContext.ts +++ b/src/createContext.ts @@ -11,7 +11,6 @@ import { import { GLOBAL, JSSLANG_PROPERTIES } from './constants' import { call_with_current_continuation } from './cse-machine/continuations' import Heap from './cse-machine/heap' -import { AsyncScheduler } from './schedulers' import * as list from './stdlib/list' import { list_to_vector } from './stdlib/list' import { listPrelude } from './stdlib/list.prelude' @@ -120,8 +119,7 @@ const createEmptyDebugger = () => ({ state: { it: (function* (): any { return - })(), - scheduler: new AsyncScheduler() + })() } }) diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc-js.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc-js.ts.snap deleted file mode 100644 index 459de6d64..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc-js.ts.snap +++ /dev/null @@ -1,77 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`call_cc can be used to return early: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 1; -call_cc((cont) => { - x = 2; - cont(); - x = 3; -}); -x;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`call_cc throws error when given > 1 arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (cont) => cont; -1 + 2 + call_cc(f,f) + 4;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`call_cc throws error when given no arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1 + 2 + call_cc() + 4;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`call_cc works with normal functions: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 + 2 + call_cc((cont) => 3) + 4;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`continuations can be stored as a value: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let a = 0; -call_cc((cont) => { - a = cont; -}); -a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": [Function], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc.ts.snap deleted file mode 100644 index df1220603..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine-callcc.ts.snap +++ /dev/null @@ -1,100 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`basic call/cc works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (+ 1 2 (call/cc - (lambda (k) (k 3))) - 4) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 10n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`call/cc can be stored as a value: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - ;; storing a continuation - (define a #f) - - (+ 1 2 3 (call/cc (lambda (k) (set! a k) 0)) 4 5) - - ;; continuations are treated as functions - ;; so we can do this: - (procedure? a) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`call/cc can be used to escape a computation: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define test 1) - (call/cc (lambda (k) - (set! test 2) - (k 'escaped) - (set! test 3))) - ;; test should be 2 - test - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 2n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`call/cc throws error given >1 argument: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (+ 1 2 (call/cc - (lambda (k) (k 3)) - 'wrongwrongwrong!) - 4) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`call/cc throws error given no arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (+ 1 2 (call/cc) 4) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine-errors.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine-errors.ts.snap deleted file mode 100644 index 5d412190e..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine-errors.ts.snap +++ /dev/null @@ -1,1049 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Builtins don't create additional errors when it's not their fault: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return a; -} -map(f, list(1, 2));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Name a not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot overwrite loop variables within a block: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let z = []; - for (let x = 0; x < 2; x = x + 1) { - x = 1; - } - return false; -} -test();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Assignment to a for loop variable in the for loop is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cascading js errors work properly: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function h(p) { - return head(p); -} - -h(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when accessing temporal dead zone: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = 1; -function f() { - display(a); - const a = 5; -} -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name a declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -map = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Cannot assign new value to constant map. -As map was declared as a constant, its value cannot be changed. You will have to declare a new variable. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -undefined = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Cannot assign new value to constant undefined. -As undefined was declared as a constant, its value cannot be changed. You will have to declare a new variable. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "map = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Cannot assign new value to constant map.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "undefined = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Cannot assign new value to constant undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function in tail call with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -const g = () => 1; -const f = x => g(x); -f(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 15: Expected 0 arguments, but got 1. -Try calling function g again, but with 0 arguments instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function in tail call with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const g = () => 1; -const f = x => g(x); -f(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 0 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too few arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = x => x; - f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 0. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = x => x; - f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 2. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling builtin function in with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(\\"\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 2 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling builtin function in with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(1, 2, 3);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 arguments, but got 3.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function from member expression with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = [x => x]; - f[0](1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 2. -Try calling function f[0] again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function from member expression with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = [x => x]; -f[0](1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too few arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - function f(x) { - return x; - } - f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 5, Column 2: Expected 1 arguments, but got 0. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - function f(x) { - return x; - } - f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 5, Column 2: Expected 1 arguments, but got 2. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value "string" - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - 'string'();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value \\"string\\". -Because \\"string\\" is not a function, you cannot run \\"string\\"(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value "string": expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "'string'();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value \\"string\\".", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value 0 - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - 0();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value 0. -Because 0 is not a function, you cannot run 0(). If you were planning to perform multiplication by 0, you need to use the * operator. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value 0: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "0();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value array - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -[1]();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Calling non-function value [1]. -Because [1] is not a function, you cannot run [1](). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value array: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[1]();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value [1].", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value null - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - null();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: null literals are not allowed. -They're not part of the Source §1 specs. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value null: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "null();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: null literals are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value true - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - true();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value true. -Because true is not a function, you cannot run true(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value true: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "true();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value true.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - undefined();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value undefined. -Because undefined is not a function, you cannot run undefined(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined with arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - undefined(1, true);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value undefined. -Because undefined is not a function, you cannot run undefined(1, true). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined with arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "undefined(1, true);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "undefined();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring const after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 6: SyntaxError: Identifier 'f' has already been declared (3:6) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring const after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring constant as variable: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring constant: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after const --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -const f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after const: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after let --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after let: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring let after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 4: SyntaxError: Identifier 'f' has already been declared (3:4) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring let after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring variable as constant: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring variable: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error with too few arguments passed to rest parameters: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function rest(a, b, ...c) {} -rest(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 2 or more arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error with too many arguments passed to math_sin: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "math_sin(7,8);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`In a block, every going-to-be-defined variable in the block cannot be accessed until it has been defined in the block.: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = 1; -{ - a + a; - const a = 10; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name a declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Nice errors when errors occur inside builtins: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(\\"10\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 2 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Nice errors when errors occur inside builtins: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"'\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: ParseError: SyntaxError: Unterminated string constant (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling display function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(1); -display(1, \\"test\\");", - "displayResult": Array [ - "1", - "test 1", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling list function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list(); -list(1); -list(1, 2, 3); -list(1, 2, 3, 4, 5, 6, 6);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - 2, - Array [ - 3, - Array [ - 4, - Array [ - 5, - Array [ - 6, - Array [ - 6, - null, - ], - ], - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling math_max function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "math_max(); -math_max(1, 2); -math_max(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling math_min function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "math_min(); -math_min(1, 2); -math_min(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling stringify function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(1, 2); -stringify(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "1", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No hoisting of functions. Only the name is hoisted like let and const: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const v = f(); -function f() { - return 1; -} -v;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name f declared later in current scope but not yet assigned", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Shadowed variables may not be assigned to until declared in the current scope: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let variable = 1; -function test(){ - variable = 100; - let variable = true; - return variable; -} -test();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name variable not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error with * , error line at , not : expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "12 -* -'string';", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected number on right hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error with non boolean in if statement, error line at if statement, not at 1: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "if ( -1 -) { - 2; -} else {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected boolean as condition, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Undefined variable error is thrown - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -im_undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Name im_undefined not declared. -Before you can read the value of im_undefined, you need to declare it as a variable or a constant. You can do this using the let or const keywords. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Undefined variable error is thrown: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "im_undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name im_undefined not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Undefined variables are caught even when unreached: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = 1; -if (false) { - im_undefined; -} else { - a; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Name im_undefined not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine-return-regressions.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine-return-regressions.ts.snap deleted file mode 100644 index 4a6940382..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine-return-regressions.ts.snap +++ /dev/null @@ -1,359 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Bare early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return i+1; - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - if (true) { - return 1; - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - while (true) { - return 1; - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Bare early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - return 1; - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Calling unreachable results in error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function f() { - unreachable(); - return 0; - } - f(); - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Expected number on right hand side of operation, got boolean.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return id(i+1) + id(i+2); - } - return 0; - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - if (true) { - return id(1) + id(2); - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - while (true) { - return id(1) + id(2); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Recursive call early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - return id(1) + id(2); - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in for loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - for (let i = 0; i < 100; i = i + 1) { - return id(i+1); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in if statements work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - if (true) { - return id(1); - unreachable(); - } else {} - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns in while loops work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - while (true) { - return id(1); - unreachable(); - } - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call early returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - function unreachable() { - return 1 < true; // Will cause an error - } - function id(x) { - return x; - } - function f() { - return id(1); - unreachable(); - return 0; - unreachable(); - } - f(); - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine-stdlib.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine-stdlib.ts.snap index ef86d0b26..7db840268 100644 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine-stdlib.ts.snap +++ b/src/cse-machine/__tests__/__snapshots__/cse-machine-stdlib.ts.snap @@ -1,621 +1,13 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Builtins work as expected 0: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display('message');", - "displayResult": Array [ - "\\"message\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "message", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 1 1`] = `"Line 1: Error: \\"error!\\""`; -exports[`Builtins work as expected 1: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "error('error!');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: \\"error!\\"", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 40 1`] = `"Line 1: Error: head(xs) expects a pair as argument xs, but encountered null"`; -exports[`Builtins work as expected 2: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_undefined(undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 41 1`] = `"Line 1: Error: tail(xs) expects a pair as argument xs, but encountered null"`; -exports[`Builtins work as expected 3: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_undefined(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 42 1`] = `"Line 1: Error: head(xs) expects a pair as argument xs, but encountered 1"`; -exports[`Builtins work as expected 4: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_null(undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 43 1`] = `"Line 1: Error: tail(xs) expects a pair as argument xs, but encountered 1"`; -exports[`Builtins work as expected 5: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_null(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 6: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 7: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 8: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 9: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 10: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_string(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 11: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 12: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 13: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 14: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 15: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 16: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('string');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 17: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('true');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 18: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean('1');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 19: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean(true);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 20: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_boolean(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 21: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(display);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 22: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(x => x);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 23: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -is_function(f);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 24: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_function(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 25: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 26: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 27: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_array([1]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 28: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "array_length([1]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 29: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 10);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 30: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 31: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(get_time());", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 32: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const start = get_time(); -function repeatUntilDifferentTime() { - if (start === get_time()) { - return repeatUntilDifferentTime(); - } else { - return true; - } -} -repeatUntilDifferentTime();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 33: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "pair(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - 2, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 34: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - 2, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 35: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 36: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 37: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "is_list(list(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 38: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "head(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 39: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(pair(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 40: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "head(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 41: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: tail(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 42: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "head(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: head(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 43: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: tail(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 44: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "length(list(1, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins work as expected 45: fails 1`] = ` -Object { - "alertResult": Array [], - "code": "length(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 33: Error: tail(xs) expects a pair as argument xs, but encountered 1", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Builtins work as expected 45 1`] = `"Line 33: Error: tail(xs) expects a pair as argument xs, but encountered 1"`; diff --git a/src/cse-machine/__tests__/__snapshots__/cse-machine.ts.snap b/src/cse-machine/__tests__/__snapshots__/cse-machine.ts.snap deleted file mode 100644 index 68b85f4c7..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cse-machine.ts.snap +++ /dev/null @@ -1,568 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Array literals are unpacked in the correct order: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let d = 0; -let c = [ d = d * 10 + 1, d = d * 10 + 2, d = d * 10 + 3]; -d;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 123, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Array literals work as expected: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let c = [1, 2, 3]; -c;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - 2, - 3, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Breaks, continues and returns are detected properly inside loops: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - let i = 0; - while(i < 10) { - i = i + 1; - if (i === 1) { - i = 1; - i = 1; - } else if (i === 2) { - i = 2; - continue; - } else if (i === 3) { - i = 3; - return i; - } else if (i === 4) { - i = 4; - break; - } - } - return i; -} -f();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Conditional statements are value producing always: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function fact(n) { - if (n === 0) { - 2; - return 1; - } - if (true) { - let i = 1; - i = i - 1; - } else { - 2; - } - if (false) { - 2; - } else { - const i = 1; - } - return n * fact(n - 1); - } -fact(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 120, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Environment reset is inserted when only instructions are in control stack: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const a = (v => v)(0);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Nullary functions properly restore environment 1: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - function g(t) { - return 0; - } - return g; -} -const h = f(); -h(100);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Nullary functions properly restore environment 2: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - const a = 1; - return a; -} -const a = f(); -a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Simple tail call returns work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in boolean operators work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return false || f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in conditional expressions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x <= 0 ? y : f(x-1, y+1); -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail call in nested mix of conditional expressions boolean operators work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x <= 0 ? y : false || x > 0 ? f(x-1, y+1) : 'unreachable'; -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in arrow block functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -}; -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in arrow functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => x <= 0 ? y : f(x-1, y+1); -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mixed tail-call/non-tail-call recursion work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y, z) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+f(0, z, 0), z); - } -} -f(5000, 5000, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 15000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mutual recursion with arrow functions work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = (x, y) => x <= 0 ? y : g(x-1, y+1); -const g = (x, y) => x <= 0 ? y : f(x-1, y+1); -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Tail calls in mutual recursion work: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - if (x <= 0) { - return y; - } else { - return g(x-1, y+1); - } -} -function g(x, y) { - if (x <= 0) { - return y; - } else { - return f(x-1, y+1); - } -} -f(5000, 5000);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10000, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`breaks, continues are properly detected in child blocks 1: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 0; -for (i = 1; i < 5; i = i + 1) { - { - const a = i; - if (i === 1) { - continue; - } - } - - { - const a = i; - if (i === 2) { - break; - } - } -} -i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`breaks, continues are properly detected in child blocks 2: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let a = 0; -for (let i = 1; i < 5; i = i + 1) { - { - const x = 0; - a = i; - if (i === 1) { - continue; - } - } - - { - const x = 0; - a = i; - if (i === 2) { - break; - } - } -} -a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`const uses block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - const x = true; - if(true) { - const x = false; - } else { - const x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`continue in while loops are working as intended: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let i = 0; - let j = false; - while (i <= 10){ - if (i === 10){ - j = true; - i = i + 1; - continue; - } - j = false; - i = i + 1; - } - return j; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for loop \`let\` variables are copied into the block scope: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let z = []; - for (let x = 0; x < 10; x = x + 1) { - z[x] = () => x; - } - return z[1](); -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for loops use block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - for (let x = 1; x > 0; x = x - 1) { - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`let uses block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - if(true) { - let x = false; - } else { - let x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standalone block statements: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - const x = true; - { - const x = false; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`streams and its pre-defined/pre-built functions are working as intended: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function make_alternating_stream(stream) { - return pair(head(stream), () => make_alternating_stream( - negate_whole_stream( - stream_tail(stream)))); -} - -function negate_whole_stream(stream) { - return pair(-head(stream), () => negate_whole_stream(stream_tail(stream))); -} - -const ones = pair(1, () => ones); -list_ref(eval_stream(make_alternating_stream(enum_stream(1, 9)), 9), 8);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 9, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`streams can be created and functions with no return statements are still evaluated properly: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const s = stream(true, false, undefined, 1, x=>x, null, -123, head); -const result = []; -stream_for_each(item => {result[array_length(result)] = item;}, s); -stream_ref(s,4)(22) === 22 && stream_ref(s,7)(pair('', '1')) === '1' && result;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`while loops use block scoping instead of function scoping: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(){ - let x = true; - while (true) { - let x = false; - break; - } - return x; -} -test();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cset-machine-apply.ts.snap b/src/cse-machine/__tests__/__snapshots__/cset-machine-apply.ts.snap deleted file mode 100644 index e640dd35d..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cset-machine-apply.ts.snap +++ /dev/null @@ -1,84 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`eval of strings: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval \\"hello\\") - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "hello", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`incorrect use of apply throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (apply) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Expected 2 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`incorrect use of apply throws error (last argument not a list): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (apply + 1 2 3) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Last argument of apply must be a list", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`multi-operand apply: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define args '(1 2 3 4 5)) - (apply + 6 7 8 9 10 args) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 55n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`two-operand apply: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define args '(1 2)) - (apply + args) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 3n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cset-machine-eval.ts.snap b/src/cse-machine/__tests__/__snapshots__/cset-machine-eval.ts.snap deleted file mode 100644 index 1d4858bf9..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cset-machine-eval.ts.snap +++ /dev/null @@ -1,224 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`eval of application: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(+ 1 2)) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 3n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of begin: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(begin 1 2 3)) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 3n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of booleans: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval #t) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of define: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define x 1)) - x - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 1n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of empty list: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '()) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Cannot evaluate null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`eval of if: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(if #t 1 2)) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 1n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of lambda: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(lambda (x) x)) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": [Function], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of numbers: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval 1) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 1n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of quote: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(quote (1 2 3))) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - SchemeInteger { - "numberType": 1, - "value": 1n, - }, - Array [ - SchemeInteger { - "numberType": 1, - "value": 2n, - }, - Array [ - SchemeInteger { - "numberType": 1, - "value": 3n, - }, - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of set!: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define x 2) - (eval '(set! x 1)) - x - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 1n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of strings: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval \\"hello\\") - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "hello", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`eval of symbols: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define hello 1) - (eval 'hello) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 1n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cset-machine-macros.ts.snap b/src/cse-machine/__tests__/__snapshots__/cset-machine-macros.ts.snap deleted file mode 100644 index 44a337150..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cset-machine-macros.ts.snap +++ /dev/null @@ -1,97 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`definition of a macro: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define-syntax my-let - (syntax-rules () - ((_ ((var expr) ...) body ...) - ((lambda (var ...) body ...) expr ...)))) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`failed usage of a macro (no matching pattern): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define-syntax my-let - (syntax-rules () - ((_ ((var expr) ...) body ...) - ((lambda (var ...) body ...) expr ...)))) - (my-let ((x 1) y) - (+ x y)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: No matching transformer found for macro my-let", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`use of a macro: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " - (define-syntax my-let - (syntax-rules () - ((_ ((var expr) ...) body ...) - ((lambda (var ...) body ...) expr ...)))) - (my-let ((x 1) (y 2)) - (+ x y)) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 3n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`use of a more complex macro (recursive): expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": " -(define-syntax define-match - (syntax-rules () - ; vars is a pair - ((_ (front . rest) val) - (begin - (if (not (pair? val)) - (error \\"define-match: vars and vals do not match\\")) - (define-match front (car val)) - (define-match rest (cdr val)))) - ; vars is nil - ((_ () val) - ; do nothing - (if #f #f)) - ; vars is a single symbol - ((_ sym val) - (define sym val)))) - (define-match ((x y) z) '((1 2) 3)) - (+ x y z) - ", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": SchemeInteger { - "numberType": 1, - "value": 6n, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/__snapshots__/cset-machine.ts.snap b/src/cse-machine/__tests__/__snapshots__/cset-machine.ts.snap deleted file mode 100644 index fc7301ef5..000000000 --- a/src/cse-machine/__tests__/__snapshots__/cset-machine.ts.snap +++ /dev/null @@ -1,376 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`evaluating a poorly formed begin throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(begin)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: begin requires at least 1 argument!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define throws error (attempt to redefine special form): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define (if x y) 4)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Cannot shadow special form if with a definition!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define throws error (ill formed define-function): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define (x 1 2 3) 4)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Invalid arguments for lambda!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define requires at least 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define throws error (too many arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define x 1 2 3)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define requires 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (attempt to shadow special form): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax if 4)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Cannot shadow special form if with a macro!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define-syntax requires 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (list is not syntax-rules): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x (foo bar))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define-syntax requires a syntax-rules transformer!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (no syntax-rules list): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x 1)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define-syntax requires a syntax-rules transformer!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (syntax is not a symbol): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax 1 4)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define-syntax requires a symbol!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (syntax-rules has non-list rules): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x (syntax-rules (x) 1))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Invalid syntax-rules rule!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (syntax-rules has non-symbol literals): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x (syntax-rules (1 2) (1 1)))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Invalid syntax-rules literals!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (syntax-rules has poor literals list): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x (syntax-rules x (1 1)))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Invalid syntax-rules literals!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (syntax-rules too few arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x (syntax-rules))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: syntax-rules requires at least 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed define-syntax throws error (too many arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(define-syntax x 1 2 3)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: define-syntax requires 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed if throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(if)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: if requires at least 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed if throws error (too many arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(if #t 1 2 3)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: if requires at most 3 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed lambda throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(lambda (1 2 3) x)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Invalid arguments for lambda!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed quote throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(quote)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: quote requires 1 argument!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed quote throws error (too many arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(quote x y)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: quote requires 1 argument!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed set! throws error (attempt to set! special form): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(set! if 4)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Cannot overwrite special form if with a value!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed set! throws error (insufficient arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(set!)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: set! requires 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a poorly formed set! throws error (too many arguments): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(set! x 1 2 3)) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: set! requires 2 arguments!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating a syntax-rules expression (should not exist outside of define-syntax): expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '(syntax-rules (x) (1 1))) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: syntax-rules must only exist within define-syntax!", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`evaluating null throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": " - (eval '()) - ", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: Cannot evaluate null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/cse-machine/__tests__/continuations.ts b/src/cse-machine/__tests__/continuations.ts index ae957fee3..27b8db157 100644 --- a/src/cse-machine/__tests__/continuations.ts +++ b/src/cse-machine/__tests__/continuations.ts @@ -1,4 +1,4 @@ -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Call_cc, Continuation, isCallWithCurrentContinuation } from '../continuations' import { Control, Stash, Transformers } from '../interpreter' diff --git a/src/cse-machine/__tests__/cse-machine-errors.ts b/src/cse-machine/__tests__/cse-machine-errors.ts index 9fa1bdc78..4c4dc199e 100644 --- a/src/cse-machine/__tests__/cse-machine-errors.ts +++ b/src/cse-machine/__tests__/cse-machine-errors.ts @@ -3,15 +3,23 @@ import * as _ from 'lodash' import { Chapter, Variant } from '../../types' import { stripIndent } from '../../utils/formatters' -import { - expectDifferentParsedErrors, - expectParsedError, - expectParsedErrorNoSnapshot, - expectResult -} from '../../utils/testing' +import { expectParsedError, expectResult, testFailure } from '../../utils/testing' +import { TestOptions } from '../../utils/testing/types' jest.spyOn(_, 'memoize').mockImplementation(func => func as any) +function expectDifferentParsedErrors(code1: string, code2: string, options: TestOptions = {}) { + return expect( + testFailure(code1, options).then(error1 => { + expect( + testFailure(code2, options).then(error2 => { + return expect(error1).not.toEqual(error2) + }) + ) + }) + ).resolves +} + const undefinedVariable = stripIndent` im_undefined; ` @@ -149,7 +157,7 @@ test("Builtins don't create additional errors when it's not their fault", () => }) test('Infinite recursion with a block bodied function', () => { - return expectParsedErrorNoSnapshot( + return expectParsedError( stripIndent` function i(n) { return n === 0 ? 0 : 1 + i(n-1); @@ -161,7 +169,7 @@ test('Infinite recursion with a block bodied function', () => { }, 15000) test('Infinite recursion with function calls in argument', () => { - return expectParsedErrorNoSnapshot( + return expectParsedError( stripIndent` function i(n, redundant) { return n === 0 ? 0 : 1 + i(n-1, r()); @@ -178,7 +186,7 @@ test('Infinite recursion with function calls in argument', () => { }, 20000) test('Infinite recursion of mutually recursive functions', () => { - return expectParsedErrorNoSnapshot( + return expectParsedError( stripIndent` function f(n) { return n === 0 ? 0 : 1 + g(n - 1); @@ -931,7 +939,7 @@ test('Cascading js errors work properly', () => { }) test('Check that stack is at most 10k in size', () => { - return expectParsedErrorNoSnapshot( + return expectParsedError( stripIndent` function f(x) { if (x <= 0) { diff --git a/src/cse-machine/__tests__/cse-machine-heap.ts b/src/cse-machine/__tests__/cse-machine-heap.ts index 3565ce6d7..fed7ab1d2 100644 --- a/src/cse-machine/__tests__/cse-machine-heap.ts +++ b/src/cse-machine/__tests__/cse-machine-heap.ts @@ -1,4 +1,4 @@ -import { mockClosure, mockContext } from '../../mocks/context' +import { mockClosure, mockContext } from '../../utils/testing/mocks' import { runCodeInSource } from '../../runner' import { Chapter } from '../../types' import { stripIndent } from '../../utils/formatters' @@ -11,7 +11,7 @@ test('Heap works correctly', () => { expect(heap1.getHeap()).toMatchInlineSnapshot(`Set {}`) const arr = [0] as EnvArray - const closure = mockClosure(true) + const closure = mockClosure() heap1.add(arr, closure) heap1.add(arr) expect(heap1.contains([0] as EnvArray)).toMatchInlineSnapshot(`false`) @@ -28,7 +28,7 @@ test('Heap works correctly', () => { `) const heap2 = new Heap() - expect(heap1.move(mockClosure(true), heap2)).toMatchInlineSnapshot(`false`) + expect(heap1.move(mockClosure(), heap2)).toMatchInlineSnapshot(`false`) expect(heap1.move(arr, heap2)).toMatchInlineSnapshot(`true`) expect(heap1.contains(arr)).toMatchInlineSnapshot(`false`) expect(heap1.getHeap()).toMatchInlineSnapshot(` diff --git a/src/cse-machine/__tests__/cse-machine-runtime-context.ts b/src/cse-machine/__tests__/cse-machine-runtime-context.ts index 4c3e48e0a..5a65ceeb8 100644 --- a/src/cse-machine/__tests__/cse-machine-runtime-context.ts +++ b/src/cse-machine/__tests__/cse-machine-runtime-context.ts @@ -1,6 +1,6 @@ import * as es from 'estree' import { IOptions } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { runCodeInSource } from '../../runner' import { Chapter, RecursivePartial } from '../../types' diff --git a/src/cse-machine/__tests__/cse-machine-stdlib.ts b/src/cse-machine/__tests__/cse-machine-stdlib.ts index a9c8d93ff..88a7c19e1 100644 --- a/src/cse-machine/__tests__/cse-machine-stdlib.ts +++ b/src/cse-machine/__tests__/cse-machine-stdlib.ts @@ -436,11 +436,7 @@ test.each([ variant: Variant.EXPLICIT_CONTROL }).toEqual(returnValue) } else { - return snapshotFailure( - stripIndent(snippet), - { chapter, variant: Variant.EXPLICIT_CONTROL }, - 'fails' - ) + return snapshotFailure(stripIndent(snippet), { chapter, variant: Variant.EXPLICIT_CONTROL }) } } ) diff --git a/src/cse-machine/__tests__/cse-machine-unique-id.ts b/src/cse-machine/__tests__/cse-machine-unique-id.ts index 75a972fef..aa421b1f1 100644 --- a/src/cse-machine/__tests__/cse-machine-unique-id.ts +++ b/src/cse-machine/__tests__/cse-machine-unique-id.ts @@ -1,4 +1,4 @@ -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter, type Context, type Environment } from '../../types' import { stripIndent } from '../../utils/formatters' import { runCodeInSource } from '../../runner' diff --git a/src/editors/ace/docTooltip/index.ts b/src/editors/ace/docTooltip/index.ts index 5d0667f32..a22685f62 100644 --- a/src/editors/ace/docTooltip/index.ts +++ b/src/editors/ace/docTooltip/index.ts @@ -4,7 +4,6 @@ import * as source_1_typed from './source_1_typed.json' import * as source_2 from './source_2.json' import * as source_2_typed from './source_2_typed.json' import * as source_3 from './source_3.json' -import * as source_3_concurrent from './source_3_concurrent.json' import * as source_3_typed from './source_3_typed.json' import * as source_4 from './source_4.json' import * as source_4_typed from './source_4_typed.json' @@ -45,7 +44,6 @@ export const SourceDocumentation = { '2': resolveImportInconsistency(source_2), '2_typed': resolveImportInconsistency(source_2_typed), '3': resolveImportInconsistency(source_3), - '3_concurrent': resolveImportInconsistency(source_3_concurrent), '3_typed': resolveImportInconsistency(source_3_typed), '4': resolveImportInconsistency(source_4), '4_typed': resolveImportInconsistency(source_4_typed), diff --git a/src/index.ts b/src/index.ts index 70262b05e..f3e007085 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,7 +34,6 @@ import { getKeywords, getProgramNames, NameDeclaration } from './name-extractor' import { htmlRunner, resolvedErrorPromise, sourceFilesRunner } from './runner' export interface IOptions { - scheduler: 'preemptive' | 'async' steps: number stepLimit: number executionMethod: ExecutionMethod @@ -253,12 +252,9 @@ export async function runFilesInContext( export function resume(result: Result): Finished | ResultError | Promise { if (result.status === 'finished' || result.status === 'error') { return result - } else if (result.status === 'suspended-cse-eval') { - const value = resumeEvaluate(result.context) - return CSEResultPromise(result.context, value) - } else { - return result.scheduler.run(result.it, result.context) } + const value = resumeEvaluate(result.context) + return CSEResultPromise(result.context, value) } export function interrupt(context: Context) { diff --git a/src/infiniteLoops/__tests__/errors.ts b/src/infiniteLoops/__tests__/errors.ts index 5ca59db4e..52f076aef 100644 --- a/src/infiniteLoops/__tests__/errors.ts +++ b/src/infiniteLoops/__tests__/errors.ts @@ -3,7 +3,7 @@ import * as es from 'estree' import { ExceptionError } from '../../errors/errors' import { RuntimeSourceError } from '../../errors/runtimeSourceError' import { TimeoutError } from '../../errors/timeoutErrors' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter } from '../../types' import { getInfiniteLoopData, diff --git a/src/infiniteLoops/__tests__/instrument.ts b/src/infiniteLoops/__tests__/instrument.ts index 56886b86a..e292ef2a0 100644 --- a/src/infiniteLoops/__tests__/instrument.ts +++ b/src/infiniteLoops/__tests__/instrument.ts @@ -1,6 +1,6 @@ import { Program } from 'estree' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter } from '../../types' import { evaluateBinaryExpression, evaluateUnaryExpression } from '../../utils/operators' @@ -12,24 +12,26 @@ import { function mockFunctionsAndState() { const theState = undefined - const functions = {} const returnFirst = (...args: any[]) => args[0] const nothing = (..._args: any[]) => {} - functions[functionNames.nothingFunction] = nothing - functions[functionNames.concretize] = returnFirst - functions[functionNames.hybridize] = returnFirst - functions[functionNames.wrapArg] = returnFirst - functions[functionNames.dummify] = returnFirst - functions[functionNames.saveBool] = returnFirst - functions[functionNames.saveVar] = returnFirst - functions[functionNames.preFunction] = nothing - functions[functionNames.returnFunction] = returnFirst - functions[functionNames.postLoop] = (_: any, res?: any) => res - functions[functionNames.enterLoop] = nothing - functions[functionNames.exitLoop] = nothing - functions[functionNames.trackLoc] = (_1: any, _2: any, fn?: any) => (fn ? fn() : undefined) - functions[functionNames.evalB] = evaluateBinaryExpression - functions[functionNames.evalU] = evaluateUnaryExpression + + const functions = { + [functionNames.nothingFunction]: nothing, + [functionNames.concretize]: returnFirst, + [functionNames.hybridize]: returnFirst, + [functionNames.wrapArg]: returnFirst, + [functionNames.dummify]: returnFirst, + [functionNames.saveBool]: returnFirst, + [functionNames.saveVar]: returnFirst, + [functionNames.preFunction]: nothing, + [functionNames.returnFunction]: returnFirst, + [functionNames.postLoop]: (_: any, res?: any) => res, + [functionNames.enterLoop]: nothing, + [functionNames.exitLoop]: nothing, + [functionNames.trackLoc]: (_1: any, _2: any, fn?: any) => (fn ? fn() : undefined), + [functionNames.evalB]: evaluateBinaryExpression, + [functionNames.evalU]: evaluateUnaryExpression + } return [functions, theState] } diff --git a/src/infiniteLoops/__tests__/runtime.ts b/src/infiniteLoops/__tests__/runtime.ts index 9e7b92880..e12b54793 100644 --- a/src/infiniteLoops/__tests__/runtime.ts +++ b/src/infiniteLoops/__tests__/runtime.ts @@ -2,7 +2,7 @@ import type es from 'estree' import { runInContext } from '../..' import createContext from '../../createContext' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Variant } from '../../types' import { getInfiniteLoopData, InfiniteLoopError, InfiniteLoopErrorType } from '../errors' diff --git a/src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap b/src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap deleted file mode 100644 index 4f232772a..000000000 --- a/src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap +++ /dev/null @@ -1,1106 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Access local property: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 0})[\\"a\\"];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Builtins don't create additional errors when it's not their fault: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return a; -} -map(f, list(1, 2));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Name a not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cascading js errors work properly 1: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function make_alternating_stream(stream) { - return pair(head(stream), () => make_alternating_stream( - negate_whole_stream( - stream_tail(stream)))); -} - -function negate_whole_stream(stream) { - return pair(-head(stream), () => negate_whole_stream(stream_tail(stream))); -} - -const ones = pair(1, () => ones); -eval_stream(make_alternating_stream(enum_stream(1, 9)), 10);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 8: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cascading js errors work properly: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function h(p) { - return head(p); -} - -h(null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when accessing inherited property of object: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "({}).valueOf;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Cannot read inherited property valueOf of {}.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -map = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Cannot assign new value to constant map. -As map was declared as a constant, its value cannot be changed. You will have to declare a new variable. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -undefined = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Cannot assign new value to constant undefined. -As undefined was declared as a constant, its value cannot be changed. You will have to declare a new variable. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "map = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Cannot assign new value to constant map.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when assigning to builtin: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "undefined = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Cannot assign new value to constant undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function in tail call with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -const g = () => 1; -const f = x => g(x); -f(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 15: Expected 0 arguments, but got 1. -Try calling function g again, but with 0 arguments instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function in tail call with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const g = () => 1; -const f = x => g(x); -f(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 0 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too few arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = x => x; - f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 0. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = x => x; - f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 2. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling arrow function with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling builtin function in with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(\\"\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 2 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling builtin function in with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "is_number(1, 2, 3);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 arguments, but got 3.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function from member expression with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - const f = [x => x]; - f[0](1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected 1 arguments, but got 2. -Try calling function f[0] again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function from member expression with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = [x => x]; -f[0](1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too few arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - function f(x) { - return x; - } - f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 5, Column 2: Expected 1 arguments, but got 0. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too few arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected 1 arguments, but got 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too many arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - function f(x) { - return x; - } - f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 5, Column 2: Expected 1 arguments, but got 2. -Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling function with too many arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x) { - return x; -} -f(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value "string" - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - 'string'();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value \\"string\\". -Because \\"string\\" is not a function, you cannot run \\"string\\"(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value "string": expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "'string'();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value \\"string\\".", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value 0 - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - 0();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value 0. -Because 0 is not a function, you cannot run 0(). If you were planning to perform multiplication by 0, you need to use the * operator. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value 0: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "0();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value array - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -[1]();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Calling non-function value [1]. -Because [1] is not a function, you cannot run [1](). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value array: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[1]();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value [1].", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value null - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - null();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: null literals are not allowed. -They're not part of the Source §1 specs. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value null: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "null();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: null literals are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value object - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -({a: 1})();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Calling non-function value {\\"a\\": 1}. -Because {\\"a\\": 1} is not a function, you cannot run {\\"a\\": 1}(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value object - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -({a: 1})();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Calling non-function value {\\"a\\": 1}. -Because {\\"a\\": 1} is not a function, you cannot run {\\"a\\": 1}(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value object: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1})();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value {\\"a\\": 1}.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value true - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - true();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value true. -Because true is not a function, you cannot run true(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value true: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "true();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value true.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - undefined();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value undefined. -Because undefined is not a function, you cannot run undefined(). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined with arguments - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; - undefined(1, true);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Calling non-function value undefined. -Because undefined is not a function, you cannot run undefined(1, true). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined with arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "undefined(1, true);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when calling non function value undefined: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "undefined();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Calling non-function value undefined.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring const after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 6: SyntaxError: Identifier 'f' has already been declared (3:6) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring const after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring constant as variable: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring constant: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after const --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -const f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after const: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after let --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring function after let: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -function f() {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring let after function --verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() {} -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 4: SyntaxError: Identifier 'f' has already been declared (3:4) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring let after function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() {} -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring variable as constant: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -const f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error when redeclaring variable: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = x => x; -let f = x => x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error with too few arguments passed to rest parameters: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function rest(a, b, ...c) {} -rest(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected 2 or more arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Error with too many arguments passed to math_sin: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "math_sin(7,8);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Nice errors when errors occur inside builtins: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(\\"10\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 2 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Nice errors when errors occur inside builtins: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"'\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: ParseError: SyntaxError: Unterminated string constant (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling display function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(1); -display(1, \\"test\\");", - "displayResult": Array [ - "1", - "test 1", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling list function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list(); -list(1); -list(1, 2, 3); -list(1, 2, 3, 4, 5, 6, 6);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - 2, - Array [ - 3, - Array [ - 4, - Array [ - 5, - Array [ - 6, - Array [ - 6, - null, - ], - ], - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling math_max function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "math_max(); -math_max(1, 2); -math_max(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling math_min function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "math_min(); -math_min(1, 2); -math_min(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`No error when calling stringify function in with variable arguments: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(1, 2); -stringify(1, 2, 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "1", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Type error when accessing property of function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - return 1; -} -f.prototype;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected object or array, got function.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error when accessing property of null: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "null.prop;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected object or array, got null.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error when accessing property of string: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "'hi'.length;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected object or array, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error when assigning property of function: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - return 1; -} -f.prop = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Expected object or array, got function.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error when assigning property of string: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "'hi'.prop = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected object or array, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error with * , error line at , not : expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "12 -* -'string';", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected number on right hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Type error with non boolean in if statement, error line at if statement, not at 1: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "if ( -1 -) { - 2; -} else {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected boolean as condition, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Undefined variable error is thrown - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -im_undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Name im_undefined not declared. -Before you can read the value of im_undefined, you need to declare it as a variable or a constant. You can do this using the let or const keywords. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Undefined variable error is thrown: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "im_undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name im_undefined not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/interpreter/__tests__/interpreter-errors.ts b/src/interpreter/__tests__/interpreter-errors.ts deleted file mode 100644 index c12848a00..000000000 --- a/src/interpreter/__tests__/interpreter-errors.ts +++ /dev/null @@ -1,1127 +0,0 @@ -// import type { FunctionLike, MockedFunction } from 'jest-mock' - -/* tslint:disable:max-line-length */ -// import { memoizedGetModuleManifest } from '../../modules/moduleLoader' -import { Chapter } from '../../types' -import { stripIndent } from '../../utils/formatters' -import { - expectDifferentParsedErrors, - expectParsedError, - expectParsedErrorNoSnapshot, - expectResult -} from '../../utils/testing' - -jest.mock('../../modules/loader/loaders') - -// const asMock = (func: T) => func as MockedFunction -// const mockedModuleFile = asMock(memoizedGetModuleFile) - -const undefinedVariable = stripIndent` -im_undefined; -` -const undefinedVariableVerbose = stripIndent` -"enable verbose"; -im_undefined; -` - -test('Undefined variable error is thrown', () => { - return expectParsedError(undefinedVariable).toMatchInlineSnapshot( - `"Line 1: Name im_undefined not declared."` - ) -}) - -test('Undefined variable error is thrown - verbose', () => { - return expectParsedError(undefinedVariableVerbose).toMatchInlineSnapshot(` - "Line 2, Column 0: Name im_undefined not declared. - Before you can read the value of im_undefined, you need to declare it as a variable or a constant. You can do this using the let or const keywords. - " - `) -}) - -test('Undefined variable error message differs from verbose version', () => { - return expectDifferentParsedErrors(undefinedVariable, undefinedVariableVerbose).toBe(undefined) -}) - -const assignToBuiltin = stripIndent` -map = 5; -` - -const assignToBuiltinVerbose = stripIndent` - "enable verbose"; - map = 5; -` - -test('Error when assigning to builtin', () => { - return expectParsedError(assignToBuiltin, { chapter: Chapter.SOURCE_3 }).toMatchInlineSnapshot( - `"Line 1: Cannot assign new value to constant map."` - ) -}) - -test('Error when assigning to builtin - verbose', () => { - return expectParsedError(assignToBuiltinVerbose, { chapter: Chapter.SOURCE_3 }) - .toMatchInlineSnapshot(` - "Line 2, Column 0: Cannot assign new value to constant map. - As map was declared as a constant, its value cannot be changed. You will have to declare a new variable. - " - `) -}) - -test('Assigning to builtin error message differs from verbose version', () => { - return expectDifferentParsedErrors(assignToBuiltin, assignToBuiltinVerbose).toBe(undefined) -}) - -const assignToBuiltin1 = stripIndent` -undefined = 5; -` - -const assignToBuiltinVerbose1 = stripIndent` - "enable verbose"; - undefined = 5; -` - -test('Error when assigning to builtin', () => { - return expectParsedError(assignToBuiltin1, { chapter: Chapter.SOURCE_3 }).toMatchInlineSnapshot( - `"Line 1: Cannot assign new value to constant undefined."` - ) -}) - -test('Error when assigning to builtin - verbose', () => { - return expectParsedError(assignToBuiltinVerbose1, { chapter: Chapter.SOURCE_3 }) - .toMatchInlineSnapshot(` - "Line 2, Column 0: Cannot assign new value to constant undefined. - As undefined was declared as a constant, its value cannot be changed. You will have to declare a new variable. - " - `) -}) - -test('Assigning to builtin error message differs from verbose version', () => { - return expectDifferentParsedErrors(assignToBuiltin1, assignToBuiltinVerbose1).toBe(undefined) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when assigning to property on undefined', () => { - return expectParsedError( - stripIndent` - undefined.prop = 123; - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 1: Cannot assign property prop of undefined"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when assigning to property on variable with value undefined', () => { - return expectParsedError( - stripIndent` - const u = undefined; - u.prop = 123; - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 2: Cannot assign property prop of undefined"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when deeply assigning to property on variable with value undefined', () => { - return expectParsedError( - stripIndent` - const u = undefined; - u.prop.prop = 123; - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 2: Cannot read property prop of undefined"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing property on undefined', () => { - return expectParsedError( - stripIndent` - undefined.prop; - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 1: Cannot read property prop of undefined"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when deeply accessing property on undefined', () => { - return expectParsedError( - stripIndent` - undefined.prop.prop; - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 1: Cannot read property prop of undefined"`) -}) - -test('Nice errors when errors occur inside builtins', () => { - return expectParsedError( - stripIndent` - parse_int("10"); - `, - { chapter: Chapter.SOURCE_4 } - ).toMatchInlineSnapshot(`"Line 1: Expected 2 arguments, but got 1."`) -}) - -test('Nice errors when errors occur inside builtins', () => { - return expectParsedError( - stripIndent` - parse("'"); - `, - { chapter: Chapter.SOURCE_4 } - ).toMatchInlineSnapshot(`"Line 1: ParseError: SyntaxError: Unterminated string constant (1:0)"`) -}) - -test("Builtins don't create additional errors when it's not their fault", () => { - return expectParsedError( - stripIndent` - function f(x) { - return a; - } - map(f, list(1, 2)); - `, - { chapter: Chapter.SOURCE_4 } - ).toMatchInlineSnapshot(`"Line 2: Name a not declared."`) -}) - -test('Infinite recursion with a block bodied function', () => { - return expectParsedErrorNoSnapshot( - stripIndent` - function i(n) { - return n === 0 ? 0 : 1 + i(n-1); - } - i(1000); - `, - { chapter: Chapter.SOURCE_4 } - ).toEqual(expect.stringMatching(/Maximum call stack size exceeded\n *(i\(\d*\)[^i]{2,4}){3}/)) -}, 15000) - -test('Infinite recursion with function calls in argument', () => { - return expectParsedErrorNoSnapshot( - stripIndent` - function i(n, redundant) { - return n === 0 ? 0 : 1 + i(n-1, r()); - } - function r() { - return 1; - } - i(1000, 1); - `, - { chapter: Chapter.SOURCE_4 } - ).toEqual( - expect.stringMatching(/Maximum call stack size exceeded\n *(i\(\d*, 1\)[^i]{2,4}){2}[ir]/) - ) -}, 10000) - -test('Infinite recursion of mutually recursive functions', () => { - return expectParsedErrorNoSnapshot( - stripIndent` - function f(n) { - return n === 0 ? 0 : 1 + g(n - 1); - } - function g(n) { - return 1 + f(n); - } - f(1000); - `, - { chapter: Chapter.SOURCE_4 } - ).toEqual( - expect.stringMatching( - /Maximum call stack size exceeded\n([^f]*f[^g]*g[^f]*f|[^g]*g[^f]*f[^g]*g)/ - ) - ) -}) - -const callingNonFunctionValueUndefined = stripIndent` -undefined(); -` - -const callingNonFunctionValueUndefinedVerbose = stripIndent` -"enable verbose"; - undefined(); -` -// should not be different when error passing is fixed -test('Error when calling non function value undefined', () => { - return expectParsedError(callingNonFunctionValueUndefined, { - native: true - }).toMatchInlineSnapshot(`"Line 1: Calling non-function value undefined."`) -}) - -test('Error when calling non function value undefined - verbose', () => { - return expectParsedError(callingNonFunctionValueUndefinedVerbose).toMatchInlineSnapshot(` - "Line 2, Column 2: Calling non-function value undefined. - Because undefined is not a function, you cannot run undefined(). - " - `) -}) - -test('Calling non function value undefined error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueUndefined, - callingNonFunctionValueUndefinedVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValueUndefinedArgs = stripIndent` -undefined(1, true); -` - -const callingNonFunctionValueUndefinedArgsVerbose = stripIndent` -"enable verbose"; - undefined(1, true); -` -// should not be different when error passing is fixed -test('Error when calling non function value undefined with arguments', () => { - return expectParsedError(callingNonFunctionValueUndefinedArgs, { - native: false - }).toMatchInlineSnapshot(`"Line 1: Calling non-function value undefined."`) -}) - -test('Error when calling non function value undefined with arguments - verbose', () => { - return expectParsedError(callingNonFunctionValueUndefinedArgsVerbose).toMatchInlineSnapshot(` - "Line 2, Column 2: Calling non-function value undefined. - Because undefined is not a function, you cannot run undefined(1, true). - " - `) -}) - -test('Calling non function value undefined with arguments error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueUndefinedArgs, - callingNonFunctionValueUndefinedArgsVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValueNull = stripIndent` -null(); -` - -const callingNonFunctionValueNullVerbose = stripIndent` -"enable verbose"; - null(); -` - -test('Error when calling non function value null', () => { - return expectParsedError(callingNonFunctionValueNull).toMatchInlineSnapshot( - `"Line 1: null literals are not allowed."` - ) -}) - -test('Error when calling non function value null - verbose', () => { - return expectParsedError(callingNonFunctionValueNullVerbose).toMatchInlineSnapshot(` - "Line 2, Column 2: null literals are not allowed. - They're not part of the Source §1 specs. - " - `) -}) - -test('Calling non function value null error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueNull, - callingNonFunctionValueNullVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValueTrue = stripIndent` -true(); -` -const callingNonFunctionValueTrueVerbose = stripIndent` -"enable verbose"; - true(); -` - -test('Error when calling non function value true', () => { - return expectParsedError(callingNonFunctionValueTrue, { native: true }).toMatchInlineSnapshot( - `"Line 1: Calling non-function value true."` - ) -}) - -test('Error when calling non function value true - verbose', () => { - return expectParsedError(callingNonFunctionValueTrueVerbose).toMatchInlineSnapshot(` - "Line 2, Column 2: Calling non-function value true. - Because true is not a function, you cannot run true(). - " - `) -}) - -test('Calling non function value true error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueTrue, - callingNonFunctionValueTrueVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValue0 = stripIndent` -0(); -` - -const callingNonFunctionValue0Verbose = stripIndent` -"enable verbose"; - 0(); -` - -test('Error when calling non function value 0', () => { - return expectParsedError(callingNonFunctionValue0, { native: true }).toMatchInlineSnapshot( - `"Line 1: Calling non-function value 0."` - ) -}) - -test('Error when calling non function value 0 - verbose', () => { - return expectParsedError(callingNonFunctionValue0Verbose).toMatchInlineSnapshot(` - "Line 2, Column 2: Calling non-function value 0. - Because 0 is not a function, you cannot run 0(). If you were planning to perform multiplication by 0, you need to use the * operator. - " - `) -}) - -test('Calling non function value 0 error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValue0, - callingNonFunctionValue0Verbose - ).toBe(undefined) -}) - -const callingNonFunctionValueString = stripIndent` -'string'(); -` - -const callingNonFunctionValueStringVerbose = stripIndent` -"enable verbose"; - 'string'(); -` - -test('Error when calling non function value "string"', () => { - return expectParsedError(callingNonFunctionValueString, { native: true }).toMatchInlineSnapshot( - `"Line 1: Calling non-function value \\"string\\"."` - ) -}) - -test('Error when calling non function value "string" - verbose', () => { - return expectParsedError(callingNonFunctionValueStringVerbose).toMatchInlineSnapshot(` - "Line 2, Column 2: Calling non-function value \\"string\\". - Because \\"string\\" is not a function, you cannot run \\"string\\"(). - " - `) -}) - -test('Calling non function value string error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueString, - callingNonFunctionValueStringVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValueArray = stripIndent` -[1](); -` - -const callingNonFunctionValueArrayVerbose = stripIndent` -"enable verbose"; -[1](); -` - -test('Error when calling non function value array', () => { - return expectParsedError(callingNonFunctionValueArray, { - chapter: Chapter.SOURCE_3, - native: true - }).toMatchInlineSnapshot(`"Line 1: Calling non-function value [1]."`) -}) - -test('Error when calling non function value array - verbose', () => { - return expectParsedError(callingNonFunctionValueArrayVerbose, { chapter: Chapter.SOURCE_3 }) - .toMatchInlineSnapshot(` - "Line 2, Column 0: Calling non-function value [1]. - Because [1] is not a function, you cannot run [1](). - " - `) -}) - -test('Calling non function value array error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueArray, - callingNonFunctionValueArrayVerbose - ).toBe(undefined) -}) - -const callingNonFunctionValueObject = stripIndent` -({a: 1})(); -` - -const callingNonFunctionValueObjectVerbose = stripIndent` -"enable verbose"; -({a: 1})(); -` - -test('Error when calling non function value object', () => { - return expectParsedError(callingNonFunctionValueObject, { - chapter: Chapter.LIBRARY_PARSER - }).toMatchInlineSnapshot(`"Line 1: Calling non-function value {\\"a\\": 1}."`) -}) - -test('Error when calling non function value object - verbose', () => { - return expectParsedError(callingNonFunctionValueObjectVerbose, { - chapter: Chapter.LIBRARY_PARSER - }).toMatchInlineSnapshot(` - "Line 2, Column 0: Calling non-function value {\\"a\\": 1}. - Because {\\"a\\": 1} is not a function, you cannot run {\\"a\\": 1}(). - " - `) -}) - -test('Calling non function value object error message differs from verbose version', () => { - return expectDifferentParsedErrors( - callingNonFunctionValueObject, - callingNonFunctionValueObjectVerbose - ).toBe(undefined) -}) - -test('Error when calling non function value object - verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - ({a: 1})(); - `, - { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(` - "Line 2, Column 0: Calling non-function value {\\"a\\": 1}. - Because {\\"a\\": 1} is not a function, you cannot run {\\"a\\": 1}(). - " - `) -}) - -test('Error when calling function with too few arguments', () => { - return expectParsedError( - stripIndent` - function f(x) { - return x; - } - f(); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 4: Expected 1 arguments, but got 0."`) -}) - -test('Error when calling function with too few arguments - verbose', () => { - return expectParsedError(stripIndent` - "enable verbose"; - function f(x) { - return x; - } - f(); - `).toMatchInlineSnapshot(` - "Line 5, Column 2: Expected 1 arguments, but got 0. - Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling function with too many arguments', () => { - return expectParsedError( - stripIndent` - function f(x) { - return x; - } - f(1, 2); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 4: Expected 1 arguments, but got 2."`) -}) - -test('Error when calling function with too many arguments - verbose', () => { - return expectParsedError(stripIndent` - "enable verbose"; - function f(x) { - return x; - } - f(1, 2); - `).toMatchInlineSnapshot(` - "Line 5, Column 2: Expected 1 arguments, but got 2. - Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling arrow function with too few arguments', () => { - return expectParsedError( - stripIndent` - const f = x => x; - f(); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 2: Expected 1 arguments, but got 0."`) -}) - -test('Error when calling arrow function with too few arguments - verbose', () => { - return expectParsedError(stripIndent` - "enable verbose"; - const f = x => x; - f(); - `).toMatchInlineSnapshot(` - "Line 3, Column 2: Expected 1 arguments, but got 0. - Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling arrow function with too many arguments', () => { - return expectParsedError( - stripIndent` - const f = x => x; - f(1, 2); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 2: Expected 1 arguments, but got 2."`) -}) - -test('Error when calling arrow function with too many arguments - verbose', () => { - return expectParsedError(stripIndent` - "enable verbose"; - const f = x => x; - f(1, 2); - `).toMatchInlineSnapshot(` - "Line 3, Column 2: Expected 1 arguments, but got 2. - Try calling function f again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling function from member expression with too many arguments', () => { - return expectParsedError( - stripIndent` - const f = [x => x]; - f[0](1, 2); - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: Expected 1 arguments, but got 2."`) -}) - -test('Error when calling function from member expression with too many arguments - verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - const f = [x => x]; - f[0](1, 2); - `, - { chapter: Chapter.SOURCE_3 } - ).toMatchInlineSnapshot(` - "Line 3, Column 2: Expected 1 arguments, but got 2. - Try calling function f[0] again, but with 1 argument instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling arrow function in tail call with too many arguments - verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - const g = () => 1; - const f = x => g(x); - f(1); - ` - ).toMatchInlineSnapshot(` - "Line 3, Column 15: Expected 0 arguments, but got 1. - Try calling function g again, but with 0 arguments instead. Remember that arguments are separated by a ',' (comma). - " - `) -}) - -test('Error when calling arrow function in tail call with too many arguments', () => { - return expectParsedError( - stripIndent` - const g = () => 1; - const f = x => g(x); - f(1); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 2: Expected 0 arguments, but got 1."`) -}) - -test('Error when calling builtin function in with too many arguments', () => { - return expectParsedError( - stripIndent` - is_number(1, 2, 3); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected 1 arguments, but got 3."`) -}) - -test('Error when calling builtin function in with too few arguments', () => { - return expectParsedError( - stripIndent` - parse_int(""); - `, - { native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected 2 arguments, but got 1."`) -}) - -test('No error when calling list function in with variable arguments', () => { - return expectResult( - stripIndent` - list(); - list(1); - list(1, 2, 3); - list(1, 2, 3, 4, 5, 6, 6); - `, - { native: true, chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(` - Array [ - 1, - Array [ - 2, - Array [ - 3, - Array [ - 4, - Array [ - 5, - Array [ - 6, - Array [ - 6, - null, - ], - ], - ], - ], - ], - ], - ] - `) -}) - -test('No error when calling display function in with variable arguments', () => { - return expectResult( - stripIndent` - display(1); - display(1, "test"); - `, - { native: true, chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(`1`) -}) - -test('No error when calling stringify function in with variable arguments', () => { - return expectResult( - stripIndent` - stringify(1, 2); - stringify(1, 2, 3); - `, - { native: true, chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(`"1"`) -}) - -test('No error when calling math_max function in with variable arguments', () => { - return expectResult( - stripIndent` - math_max(); - math_max(1, 2); - math_max(1, 2, 3); - `, - { native: true, chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(`3`) -}) - -test('No error when calling math_min function in with variable arguments', () => { - return expectResult( - stripIndent` - math_min(); - math_min(1, 2); - math_min(1, 2, 3); - `, - { native: true, chapter: Chapter.SOURCE_2 } - ).toMatchInlineSnapshot(`1`) -}) - -test('Error with too many arguments passed to math_sin', () => { - return expectParsedError( - stripIndent` - math_sin(7,8); - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected 1 arguments, but got 2."`) -}) - -test('Error with too few arguments passed to rest parameters', () => { - return expectParsedError( - stripIndent` - function rest(a, b, ...c) {} - rest(1); - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: Expected 2 or more arguments, but got 1."`) -}) - -test('Error when redeclaring constant', () => { - return expectParsedError( - stripIndent` - const f = x => x; - const f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)"`) -}) - -test('Error when redeclaring constant as variable', () => { - return expectParsedError( - stripIndent` - const f = x => x; - let f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)"`) -}) - -test('Error when redeclaring variable as constant', () => { - return expectParsedError( - stripIndent` - let f = x => x; - const f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)"`) -}) - -test('Error when redeclaring variable', () => { - return expectParsedError( - stripIndent` - let f = x => x; - let f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)"`) -}) - -test('Error when redeclaring function after let', () => { - return expectParsedError( - stripIndent` - let f = x => x; - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)"`) -}) - -test('Error when redeclaring function after let --verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - let f = x => x; - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) - There is a syntax error in your program - " - `) -}) - -test('Error when redeclaring function after function', () => { - return expectParsedError( - stripIndent` - function f() {} - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)"`) -}) - -test('Error when redeclaring function after function --verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - function f() {} - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) - There is a syntax error in your program - " - `) -}) - -test('Error when redeclaring function after const', () => { - return expectParsedError( - stripIndent` - const f = x => x; - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:9)"`) -}) - -test('Error when redeclaring function after const --verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - const f = x => x; - function f() {} - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - "Line 3, Column 9: SyntaxError: Identifier 'f' has already been declared (3:9) - There is a syntax error in your program - " - `) -}) - -test('Error when redeclaring const after function', () => { - return expectParsedError( - stripIndent` - function f() {} - const f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:6)"`) -}) - -test('Error when redeclaring const after function --verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - function f() {} - const f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - "Line 3, Column 6: SyntaxError: Identifier 'f' has already been declared (3:6) - There is a syntax error in your program - " - `) -}) - -test('Error when redeclaring let after function', () => { - return expectParsedError( - stripIndent` - function f() {} - let f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(`"Line 2: SyntaxError: Identifier 'f' has already been declared (2:4)"`) -}) - -test('Error when redeclaring let after function --verbose', () => { - return expectParsedError( - stripIndent` - "enable verbose"; - function f() {} - let f = x => x; - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - "Line 3, Column 4: SyntaxError: Identifier 'f' has already been declared (3:4) - There is a syntax error in your program - " - `) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing property of null', () => { - return expectParsedError( - stripIndent` - null["prop"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read property prop of null"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing property of undefined', () => { - return expectParsedError( - stripIndent` - undefined["prop"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read property prop of undefined"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of builtin', () => { - return expectParsedError( - stripIndent` - pair["constructor"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(` - "Line 1: Cannot read inherited property constructor of function pair(left, right) { - [implementation hidden] - }" - `) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of function', () => { - return expectParsedError( - stripIndent` - function f() {} - f["constructor"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 2: Cannot read inherited property constructor of function f() {}"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of arrow function', () => { - return expectParsedError( - stripIndent` - (() => 1)["constructor"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read inherited property constructor of () => 1"`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of array', () => { - return expectParsedError( - stripIndent` - [].push; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read inherited property push of []"`) -}) - -test('Error when accessing inherited property of object', () => { - return expectParsedError( - stripIndent` - ({}).valueOf; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read inherited property valueOf of {}."`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of string', () => { - return expectParsedError( - stripIndent` - 'hi'.includes; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read inherited property includes of \\"hi\\""`) -}) - -// NOTE: Obsoleted due to strict types on member access -test.skip('Error when accessing inherited property of number', () => { - return expectParsedError( - stripIndent` - (1).toPrecision; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Cannot read inherited property toPrecision of 1"`) -}) - -test('Access local property', () => { - return expectResult( - stripIndent` - ({a: 0})["a"]; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`0`) -}) - -test('Type error when accessing property of null', () => { - return expectParsedError( - stripIndent` - null.prop; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected object or array, got null."`) -}) - -test('Type error when accessing property of string', () => { - return expectParsedError( - stripIndent` - 'hi'.length; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected object or array, got string."`) -}) - -test('Type error when accessing property of function', () => { - return expectParsedError( - stripIndent` - function f() { - return 1; - } - f.prototype; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 4: Expected object or array, got function."`) -}) - -test('Type error when assigning property of string', () => { - return expectParsedError( - stripIndent` - 'hi'.prop = 5; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected object or array, got string."`) -}) - -test('Type error when assigning property of function', () => { - return expectParsedError( - stripIndent` - function f() { - return 1; - } - f.prop = 5; - `, - { chapter: Chapter.LIBRARY_PARSER, native: true } - ).toMatchInlineSnapshot(`"Line 4: Expected object or array, got function."`) -}) - -test('Type error with non boolean in if statement, error line at if statement, not at 1', () => { - return expectParsedError( - stripIndent` - if ( - 1 - ) { - 2; - } else {} - `, - { chapter: Chapter.SOURCE_1, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected boolean as condition, got number."`) -}) - -test('Type error with * , error line at , not ', () => { - return expectParsedError( - stripIndent` - 12 - * - 'string'; - `, - { chapter: Chapter.SOURCE_1, native: true } - ).toMatchInlineSnapshot(`"Line 1: Expected number on right hand side of operation, got string."`) -}) - -test('Cascading js errors work properly 1', () => { - return expectParsedError( - stripIndent` - function make_alternating_stream(stream) { - return pair(head(stream), () => make_alternating_stream( - negate_whole_stream( - stream_tail(stream)))); - } - - function negate_whole_stream(stream) { - return pair(-head(stream), () => negate_whole_stream(stream_tail(stream))); - } - - const ones = pair(1, () => ones); - eval_stream(make_alternating_stream(enum_stream(1, 9)), 10); - `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot( - `"Line 8: Error: head(xs) expects a pair as argument xs, but encountered null"` - ) -}) - -test('Cascading js errors work properly', () => { - return expectParsedError( - stripIndent` - function h(p) { - return head(p); - } - - h(null); - `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot( - `"Line 2: Error: head(xs) expects a pair as argument xs, but encountered null"` - ) -}) diff --git a/src/interpreter/closure.ts b/src/interpreter/closure.ts deleted file mode 100644 index a781d5f57..000000000 --- a/src/interpreter/closure.ts +++ /dev/null @@ -1,138 +0,0 @@ -/* tslint:disable:max-classes-per-file */ -import { generate } from 'astring' -import * as es from 'estree' - -import { - hasReturnStatement, - isBlockStatement, - isStatementSequence, - uniqueId -} from '../cse-machine/utils' -import { Context, Environment, StatementSequence, Value } from '../types' -import { - blockArrowFunction, - blockStatement, - callExpression, - identifier, - returnStatement -} from '../utils/ast/astCreator' -import { apply } from './interpreter' - -const closureToJS = (value: Closure, context: Context, klass: string) => { - function DummyClass(this: Closure) { - const args: Value[] = Array.prototype.slice.call(arguments) - const gen = apply(context, value, args, callExpression(identifier(klass), args), this) - let it = gen.next() - while (!it.done) { - it = gen.next() - } - return it.value - } - Object.defineProperty(DummyClass, 'name', { - value: klass - }) - Object.setPrototypeOf(DummyClass, () => undefined) - Object.defineProperty(DummyClass, 'Inherits', { - value: (Parent: Value) => { - DummyClass.prototype = Object.create(Parent.prototype) - DummyClass.prototype.constructor = DummyClass - } - }) - DummyClass.toString = () => generate(value.originalNode) - DummyClass.call = (thisArg: Value, ...args: Value[]): any => { - return DummyClass.apply(thisArg, args) - } - return DummyClass -} - -class Callable extends Function { - constructor(f: any) { - super() - return Object.setPrototypeOf(f, new.target.prototype) - } -} - -/** - * Models function value in the interpreter environment. - */ -export default class Closure extends Callable { - public static makeFromArrowFunction( - node: es.ArrowFunctionExpression, - environment: Environment, - context: Context, - dummyReturn?: boolean, - predefined?: boolean - ) { - const functionBody: es.BlockStatement | StatementSequence = - !isBlockStatement(node.body) && !isStatementSequence(node.body) - ? blockStatement([returnStatement(node.body, node.body.loc)], node.body.loc) - : dummyReturn && !hasReturnStatement(node.body) - ? blockStatement( - [ - ...node.body.body, - returnStatement(identifier('undefined', node.body.loc), node.body.loc) - ], - node.body.loc - ) - : node.body - - const closure = new Closure( - blockArrowFunction(node.params as es.Identifier[], functionBody, node.loc), - environment, - context, - predefined - ) - - // Set the closure's node to point back at the original one - closure.originalNode = node - - return closure - } - - /** Unique ID defined for closure */ - public readonly id: string - - /** String representation of the closure */ - public functionName: string - - /** Fake closure function */ - // tslint:disable-next-line:ban-types - public fun: Function - - /** Keeps track of whether the closure is a pre-defined function */ - public preDefined?: boolean - - /** The original node that created this Closure */ - public originalNode: es.Function | es.ArrowFunctionExpression - - constructor( - public node: es.Function | es.ArrowFunctionExpression, - public environment: Environment, - context: Context, - isPredefined?: boolean - ) { - super(function (this: any, ...args: any[]) { - return funJS.apply(this, args) - }) - this.originalNode = node - this.id = uniqueId(context) - if (this.node.type === 'FunctionDeclaration' && this.node.id !== null) { - this.functionName = this.node.id.name - } else { - this.functionName = - (this.node.params.length === 1 ? '' : '(') + - this.node.params.map((o: es.Identifier) => o.name).join(', ') + - (this.node.params.length === 1 ? '' : ')') + - ' => ...' - } - // TODO: Investigate how relevant this really is. - // .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype. - const funJS = closureToJS(this, context, this.functionName) - this.fun = funJS - this.preDefined = isPredefined == undefined ? undefined : isPredefined - } - - public toString(): string { - return generate(this.originalNode) - } -} diff --git a/src/interpreter/interpreter.ts b/src/interpreter/interpreter.ts deleted file mode 100644 index ae23f7655..000000000 --- a/src/interpreter/interpreter.ts +++ /dev/null @@ -1,858 +0,0 @@ -/* tslint:disable:max-classes-per-file */ -import type es from 'estree' -import { isEmpty } from 'lodash' - -import { UNKNOWN_LOCATION } from '../constants' -import Heap from '../cse-machine/heap' -import { uniqueId } from '../cse-machine/utils' -import * as errors from '../errors/errors' -import { RuntimeSourceError } from '../errors/runtimeSourceError' -import { checkEditorBreakpoints } from '../stdlib/inspector' -import type { Context, ContiguousArrayElements, Environment, Node, Value } from '../types' -import * as create from '../utils/ast/astCreator' -import { conditionalExpression, literal, primitive } from '../utils/ast/astCreator' -import { getModuleDeclarationSource } from '../utils/ast/helpers' -import { evaluateBinaryExpression, evaluateUnaryExpression } from '../utils/operators' -import * as rttc from '../utils/rttc' -import Closure from './closure' - -class BreakValue {} - -class ContinueValue {} - -class ReturnValue { - constructor(public value: Value) {} -} - -class TailCallReturnValue { - constructor(public callee: Closure, public args: Value[], public node: es.CallExpression) {} -} - -class Thunk { - public value: Value - public isMemoized: boolean - constructor(public exp: Node, public env: Environment) { - this.isMemoized = false - this.value = null - } -} - -function* forceIt(val: any, context: Context): Value { - if (val instanceof Thunk) { - if (val.isMemoized) return val.value - - pushEnvironment(context, val.env) - const evalRes = yield* actualValue(val.exp, context) - popEnvironment(context) - val.value = evalRes - val.isMemoized = true - return evalRes - } else return val -} - -export function* actualValue(exp: Node, context: Context): Value { - const evalResult = yield* evaluate(exp, context) - const forced = yield* forceIt(evalResult, context) - return forced -} - -const createEnvironment = ( - context: Context, - closure: Closure, - args: Value[], - callExpression?: es.CallExpression -): Environment => { - const environment: Environment = { - name: closure.functionName, // TODO: Change this - tail: closure.environment, - head: {}, - heap: new Heap(), - id: uniqueId(context) - } - if (callExpression) { - environment.callExpression = { - ...callExpression, - arguments: args.map(primitive) - } - } - closure.node.params.forEach((param, index) => { - if (param.type === 'RestElement') { - environment.head[(param.argument as es.Identifier).name] = args.slice(index) - } else { - environment.head[(param as es.Identifier).name] = args[index] - } - }) - return environment -} - -export const createBlockEnvironment = ( - context: Context, - name = 'blockEnvironment' -): Environment => { - return { - name, - tail: currentEnvironment(context), - head: {}, - heap: new Heap(), - id: uniqueId(context) - } -} - -const handleRuntimeError = (context: Context, error: RuntimeSourceError): never => { - context.errors.push(error) - context.runtime.environments = context.runtime.environments.slice( - -context.numberOfOuterEnvironments - ) - throw error -} - -const DECLARED_BUT_NOT_YET_ASSIGNED = Symbol('Used to implement block scope') - -function declareIdentifier(context: Context, name: string, node: Node) { - const environment = currentEnvironment(context) - if (environment.head.hasOwnProperty(name)) { - const descriptors = Object.getOwnPropertyDescriptors(environment.head) - - return handleRuntimeError( - context, - new errors.VariableRedeclaration(node, name, descriptors[name].writable) - ) - } - environment.head[name] = DECLARED_BUT_NOT_YET_ASSIGNED - return environment -} - -function declareVariables(context: Context, node: es.VariableDeclaration) { - for (const declaration of node.declarations) { - declareIdentifier(context, (declaration.id as es.Identifier).name, node) - } -} - -function declareFunctionsAndVariables(context: Context, node: es.BlockStatement) { - for (const statement of node.body) { - switch (statement.type) { - case 'VariableDeclaration': - declareVariables(context, statement) - break - case 'FunctionDeclaration': - if (statement.id === null) { - throw new Error( - 'Encountered a FunctionDeclaration node without an identifier. This should have been caught when parsing.' - ) - } - declareIdentifier(context, statement.id.name, statement) - break - } - } -} - -function defineVariable(context: Context, name: string, value: Value, constant = false) { - const environment = currentEnvironment(context) - - if (environment.head[name] !== DECLARED_BUT_NOT_YET_ASSIGNED) { - return handleRuntimeError( - context, - new errors.VariableRedeclaration(context.runtime.nodes[0]!, name, !constant) - ) - } - - Object.defineProperty(environment.head, name, { - value, - writable: !constant, - enumerable: true - }) - - return environment -} - -function* visit(context: Context, node: Node) { - checkEditorBreakpoints(context, node) - context.runtime.nodes.unshift(node) - yield context -} - -function* leave(context: Context) { - context.runtime.break = false - context.runtime.nodes.shift() - yield context -} - -const currentEnvironment = (context: Context) => context.runtime.environments[0] -const replaceEnvironment = (context: Context, environment: Environment) => { - context.runtime.environments[0] = environment - context.runtime.environmentTree.insert(environment) -} -const popEnvironment = (context: Context) => context.runtime.environments.shift() -export const pushEnvironment = (context: Context, environment: Environment) => { - context.runtime.environments.unshift(environment) - context.runtime.environmentTree.insert(environment) -} - -const getVariable = (context: Context, name: string) => { - let environment: Environment | null = currentEnvironment(context) - while (environment) { - if (environment.head.hasOwnProperty(name)) { - if (environment.head[name] === DECLARED_BUT_NOT_YET_ASSIGNED) { - return handleRuntimeError( - context, - new errors.UnassignedVariable(name, context.runtime.nodes[0]) - ) - } else { - return environment.head[name] - } - } else { - environment = environment.tail - } - } - return handleRuntimeError(context, new errors.UndefinedVariable(name, context.runtime.nodes[0])) -} - -const setVariable = (context: Context, name: string, value: any) => { - let environment: Environment | null = currentEnvironment(context) - while (environment) { - if (environment.head.hasOwnProperty(name)) { - if (environment.head[name] === DECLARED_BUT_NOT_YET_ASSIGNED) { - break - } - const descriptors = Object.getOwnPropertyDescriptors(environment.head) - if (descriptors[name].writable) { - environment.head[name] = value - return undefined - } - return handleRuntimeError( - context, - new errors.ConstAssignment(context.runtime.nodes[0]!, name) - ) - } else { - environment = environment.tail - } - } - return handleRuntimeError(context, new errors.UndefinedVariable(name, context.runtime.nodes[0])) -} - -const checkNumberOfArguments = ( - context: Context, - callee: Closure | Value, - args: Value[], - exp: es.CallExpression -) => { - if (callee instanceof Closure) { - const params = callee.node.params - const hasVarArgs = params[params.length - 1]?.type === 'RestElement' - if (hasVarArgs ? params.length - 1 > args.length : params.length !== args.length) { - return handleRuntimeError( - context, - new errors.InvalidNumberOfArguments( - exp, - hasVarArgs ? params.length - 1 : params.length, - args.length, - hasVarArgs - ) - ) - } - } else { - const hasVarArgs = callee.minArgsNeeded != undefined - if (hasVarArgs ? callee.minArgsNeeded > args.length : callee.length !== args.length) { - return handleRuntimeError( - context, - new errors.InvalidNumberOfArguments( - exp, - hasVarArgs ? callee.minArgsNeeded : callee.length, - args.length, - hasVarArgs - ) - ) - } - } - return undefined -} - -function* getArgs(context: Context, call: es.CallExpression) { - const args = [] - for (const arg of call.arguments) { - if (arg.type === 'SpreadElement') { - args.push(...(yield* actualValue(arg.argument, context))) - } else { - args.push(yield* actualValue(arg, context)) - } - } - return args -} - -function transformLogicalExpression(node: es.LogicalExpression): es.ConditionalExpression { - if (node.operator === '&&') { - return conditionalExpression(node.left, node.right, literal(false), node.loc) - } else { - return conditionalExpression(node.left, literal(true), node.right, node.loc) - } -} - -function* reduceIf( - node: es.IfStatement | es.ConditionalExpression, - context: Context -): IterableIterator { - const test = yield* actualValue(node.test, context) - - const error = rttc.checkIfStatement(node, test, context.chapter) - if (error) { - return handleRuntimeError(context, error) - } - - return test ? node.consequent : node.alternate -} - -export type Evaluator = (node: T, context: Context) => IterableIterator - -function* evaluateBlockStatement(context: Context, node: es.BlockStatement) { - declareFunctionsAndVariables(context, node) - let result - for (const statement of node.body) { - result = yield* evaluate(statement, context) - if ( - result instanceof ReturnValue || - result instanceof TailCallReturnValue || - result instanceof BreakValue || - result instanceof ContinueValue - ) { - break - } - } - return result -} - -/** - * WARNING: Do not use object literal shorthands, e.g. - * { - * *Literal(node: es.Literal, ...) {...}, - * *ThisExpression(node: es.ThisExpression, ..._ {...}, - * ... - * } - * They do not minify well, raising uncaught syntax errors in production. - * See: https://github.com/webpack/webpack/issues/7566 - */ -// tslint:disable:object-literal-shorthand -// prettier-ignore -export const evaluators: { [nodeType: string]: Evaluator } = { - /** Simple Values */ - Literal: function*(node: es.Literal, _context: Context) { - return node.value - }, - - TemplateLiteral: function*(node: es.TemplateLiteral) { - // Expressions like `${1}` are not allowed, so no processing needed - return node.quasis[0].value.cooked - }, - - ThisExpression: function*(node: es.ThisExpression, context: Context) { - return currentEnvironment(context).thisContext - }, - - ArrayExpression: function*(node: es.ArrayExpression, context: Context) { - const res = [] - for (const n of node.elements as ContiguousArrayElements) { - res.push(yield* evaluate(n, context)) - } - return res - }, - - DebuggerStatement: function*(node: es.DebuggerStatement, context: Context) { - context.runtime.break = true - yield - }, - - FunctionExpression: function*(node: es.FunctionExpression, context: Context) { - return new Closure(node, currentEnvironment(context), context) - }, - - ArrowFunctionExpression: function*(node: es.ArrowFunctionExpression, context: Context) { - return Closure.makeFromArrowFunction(node, currentEnvironment(context), context) - }, - - Identifier: function*(node: es.Identifier, context: Context) { - return getVariable(context, node.name) - }, - - CallExpression: function*(node: es.CallExpression, context: Context) { - const callee = yield* actualValue(node.callee, context) - const args = yield* getArgs(context, node) - let thisContext - if (node.callee.type === 'MemberExpression') { - thisContext = yield* actualValue(node.callee.object, context) - } - const result = yield* apply(context, callee, args, node, thisContext) - return result - }, - - NewExpression: function*(node: es.NewExpression, context: Context) { - const callee = yield* evaluate(node.callee, context) - const args = [] - for (const arg of node.arguments) { - args.push(yield* evaluate(arg, context)) - } - const obj: Value = {} - if (callee instanceof Closure) { - obj.__proto__ = callee.fun.prototype - callee.fun.apply(obj, args) - } else { - obj.__proto__ = callee.prototype - callee.apply(obj, args) - } - return obj - }, - - UnaryExpression: function*(node: es.UnaryExpression, context: Context) { - const value = yield* actualValue(node.argument, context) - - const error = rttc.checkUnaryExpression(node, node.operator, value, context.chapter) - if (error) { - return handleRuntimeError(context, error) - } - return evaluateUnaryExpression(node.operator, value) - }, - - BinaryExpression: function*(node: es.BinaryExpression, context: Context) { - const left = yield* actualValue(node.left, context) - const right = yield* actualValue(node.right, context) - const error = rttc.checkBinaryExpression(node, node.operator, context.chapter, left, right) - if (error) { - return handleRuntimeError(context, error) - } - return evaluateBinaryExpression(node.operator, left, right) - }, - - ConditionalExpression: function*(node: es.ConditionalExpression, context: Context) { - return yield* this.IfStatement(node, context) - }, - - LogicalExpression: function*(node: es.LogicalExpression, context: Context) { - return yield* this.ConditionalExpression(transformLogicalExpression(node), context) - }, - - VariableDeclaration: function*(node: es.VariableDeclaration, context: Context) { - const declaration = node.declarations[0] - const constant = node.kind === 'const' - const id = declaration.id as es.Identifier - const value = yield* evaluate(declaration.init!, context) - defineVariable(context, id.name, value, constant) - return undefined - }, - - ContinueStatement: function*(_node: es.ContinueStatement, _context: Context) { - return new ContinueValue() - }, - - BreakStatement: function*(_node: es.BreakStatement, _context: Context) { - return new BreakValue() - }, - - ForStatement: function*(node: es.ForStatement, context: Context) { - // Create a new block scope for the loop variables - const loopEnvironment = createBlockEnvironment(context, 'forLoopEnvironment') - pushEnvironment(context, loopEnvironment) - - const initNode = node.init! - const testNode = node.test! - const updateNode = node.update! - if (initNode.type === 'VariableDeclaration') { - declareVariables(context, initNode) - } - yield* actualValue(initNode, context) - - let value - while (yield* actualValue(testNode, context)) { - // create block context and shallow copy loop environment head - // see https://www.ecma-international.org/ecma-262/6.0/#sec-for-statement-runtime-semantics-labelledevaluation - // and https://hacks.mozilla.org/2015/07/es6-in-depth-let-and-const/ - // We copy this as a const to avoid ES6 funkiness when mutating loop vars - // https://github.com/source-academy/js-slang/issues/65#issuecomment-425618227 - const environment = createBlockEnvironment(context, 'forBlockEnvironment') - pushEnvironment(context, environment) - for (const name in loopEnvironment.head) { - if (loopEnvironment.head.hasOwnProperty(name)) { - declareIdentifier(context, name, node) - defineVariable(context, name, loopEnvironment.head[name], true) - } - } - - value = yield* actualValue(node.body, context) - - // Remove block context - popEnvironment(context) - if (value instanceof ContinueValue) { - value = undefined - } - if (value instanceof BreakValue) { - value = undefined - break - } - if (value instanceof ReturnValue || value instanceof TailCallReturnValue) { - break - } - - yield* actualValue(updateNode, context) - } - - popEnvironment(context) - - return value - }, - - MemberExpression: function*(node: es.MemberExpression, context: Context) { - let obj = yield* actualValue(node.object, context) - if (obj instanceof Closure) { - obj = obj.fun - } - let prop - if (node.computed) { - prop = yield* actualValue(node.property, context) - } else { - prop = (node.property as es.Identifier).name - } - - const error = rttc.checkMemberAccess(node, obj, prop) - if (error) { - return handleRuntimeError(context, error) - } - - if ( - obj !== null && - obj !== undefined && - typeof obj[prop] !== 'undefined' && - !obj.hasOwnProperty(prop) - ) { - return handleRuntimeError(context, new errors.GetInheritedPropertyError(node, obj, prop)) - } - try { - return obj[prop] - } catch { - return handleRuntimeError(context, new errors.GetPropertyError(node, obj, prop)) - } - }, - - AssignmentExpression: function*(node: es.AssignmentExpression, context: Context) { - if (node.left.type === 'MemberExpression') { - const left = node.left - const obj = yield* actualValue(left.object, context) - let prop - if (left.computed) { - prop = yield* actualValue(left.property, context) - } else { - prop = (left.property as es.Identifier).name - } - - const error = rttc.checkMemberAccess(node, obj, prop) - if (error) { - return handleRuntimeError(context, error) - } - - const val = yield* evaluate(node.right, context) - try { - obj[prop] = val - } catch { - return handleRuntimeError(context, new errors.SetPropertyError(node, obj, prop)) - } - return val - } - const id = node.left as es.Identifier - // Make sure it exist - const value = yield* evaluate(node.right, context) - setVariable(context, id.name, value) - return value - }, - - FunctionDeclaration: function*(node: es.FunctionDeclaration, context: Context) { - const id = node.id - if (id === null) { - throw new Error("Encountered a FunctionDeclaration node without an identifier. This should have been caught when parsing.") - } - // tslint:disable-next-line:no-any - const closure = new Closure(node, currentEnvironment(context), context) - defineVariable(context, id.name, closure, true) - return undefined - }, - - IfStatement: function*(node: es.IfStatement | es.ConditionalExpression, context: Context) { - const result = yield* reduceIf(node, context) - if (result === null) { - return undefined; - } - return yield* evaluate(result, context) - }, - - ExpressionStatement: function*(node: es.ExpressionStatement, context: Context) { - return yield* evaluate(node.expression, context) - }, - - ReturnStatement: function*(node: es.ReturnStatement, context: Context) { - let returnExpression = node.argument! - - // If we have a conditional expression, reduce it until we get something else - while ( - returnExpression.type === 'LogicalExpression' || - returnExpression.type === 'ConditionalExpression' - ) { - if (returnExpression.type === 'LogicalExpression') { - returnExpression = transformLogicalExpression(returnExpression) - } - returnExpression = yield* reduceIf(returnExpression, context) - } - - // If we are now left with a CallExpression, then we use TCO - if (returnExpression.type === 'CallExpression') { - const callee = yield* actualValue(returnExpression.callee, context) - const args = yield* getArgs(context, returnExpression) - return new TailCallReturnValue(callee, args, returnExpression) - } else { - return new ReturnValue(yield* evaluate(returnExpression, context)) - } - }, - - WhileStatement: function*(node: es.WhileStatement, context: Context) { - let value: any // tslint:disable-line - while ( - // tslint:disable-next-line - (yield* actualValue(node.test, context)) && - !(value instanceof ReturnValue) && - !(value instanceof BreakValue) && - !(value instanceof TailCallReturnValue) - ) { - value = yield* actualValue(node.body, context) - } - if (value instanceof BreakValue) { - return undefined - } - return value - }, - - ObjectExpression: function*(node: es.ObjectExpression, context: Context) { - const obj = {} - for (const propUntyped of node.properties) { - // node.properties: es.Property | es.SpreadExpression, but - // our Acorn is set to ES6 which cannot have a es.SpreadExpression - // at this point. Force the type. - const prop = propUntyped as es.Property - let key - if (prop.key.type === 'Identifier') { - key = prop.key.name - } else { - key = yield* evaluate(prop.key, context) - } - obj[key] = yield* evaluate(prop.value, context) - } - return obj - }, - - BlockStatement: function*(node: es.BlockStatement, context: Context) { - // Create a new environment (block scoping) - const environment = createBlockEnvironment(context, 'blockEnvironment') - pushEnvironment(context, environment) - const result: Value = yield* evaluateBlockStatement(context, node) - popEnvironment(context) - return result - }, - - ImportDeclaration: function*(node: es.ImportDeclaration, context: Context) { - throw new Error('ImportDeclarations should already have been removed') - }, - - ExportNamedDeclaration: function*(_node: es.ExportNamedDeclaration, _context: Context) { - // Exports are handled as a separate pre-processing step in 'transformImportedFile'. - // Subsequently, they are removed from the AST by 'removeExports' before the AST is evaluated. - // As such, there should be no ExportNamedDeclaration nodes in the AST. - throw new Error('Encountered an ExportNamedDeclaration node in the AST while evaluating. This suggests that an invariant has been broken.') - }, - - ExportDefaultDeclaration: function*(_node: es.ExportDefaultDeclaration, _context: Context) { - // Exports are handled as a separate pre-processing step in 'transformImportedFile'. - // Subsequently, they are removed from the AST by 'removeExports' before the AST is evaluated. - // As such, there should be no ExportDefaultDeclaration nodes in the AST. - throw new Error('Encountered an ExportDefaultDeclaration node in the AST while evaluating. This suggests that an invariant has been broken.') - }, - - ExportAllDeclaration: function*(_node: es.ExportAllDeclaration, _context: Context) { - // Exports are handled as a separate pre-processing step in 'transformImportedFile'. - // Subsequently, they are removed from the AST by 'removeExports' before the AST is evaluated. - // As such, there should be no ExportAllDeclaration nodes in the AST. - throw new Error('Encountered an ExportAllDeclaration node in the AST while evaluating. This suggests that an invariant has been broken.') - }, - - Program: function*(node: es.BlockStatement, context: Context) { - throw new Error('A program should not contain another program within itself') - } -} -// tslint:enable:object-literal-shorthand - -// TODO: move to util -/** - * Checks if `env` is empty (that is, head of env is an empty object) - */ -function isEmptyEnvironment(env: Environment) { - return isEmpty(env.head) -} - -/** - * Extracts the non-empty tail environment from the given environment and - * returns current environment if tail environment is a null. - */ -function getNonEmptyEnv(environment: Environment): Environment { - if (isEmptyEnvironment(environment)) { - const tailEnvironment = environment.tail - if (tailEnvironment === null) { - return environment - } - return getNonEmptyEnv(tailEnvironment) - } else { - return environment - } -} - -export function* evaluateProgram(program: es.Program, context: Context) { - yield* visit(context, program) - - context.numberOfOuterEnvironments += 1 - const environment = createBlockEnvironment(context, 'programEnvironment') - pushEnvironment(context, environment) - - const otherNodes: es.Statement[] = [] - - try { - for (const node of program.body) { - if (node.type !== 'ImportDeclaration') { - otherNodes.push(node as es.Statement) - continue - } - - yield* visit(context, node) - - const moduleName = getModuleDeclarationSource(node) - const functions = context.nativeStorage.loadedModules[moduleName] - - for (const spec of node.specifiers) { - declareIdentifier(context, spec.local.name, node) - let obj: any - - switch (spec.type) { - case 'ImportSpecifier': { - obj = functions[spec.imported.name] - break - } - case 'ImportDefaultSpecifier': { - obj = functions.default - break - } - case 'ImportNamespaceSpecifier': { - obj = functions - break - } - } - - defineVariable(context, spec.local.name, obj, true) - } - yield* leave(context) - } - } catch (error) { - handleRuntimeError(context, error) - } - - const newProgram = create.blockStatement(otherNodes) - const result = yield* forceIt(yield* evaluateBlockStatement(context, newProgram), context) - - yield* leave(context) // Done visiting program - - if (result instanceof Closure) { - Object.defineProperty(getNonEmptyEnv(currentEnvironment(context)).head, uniqueId(context), { - value: result, - writable: false, - enumerable: true - }) - } - return result -} - -function* evaluate(node: Node, context: Context) { - yield* visit(context, node) - const result = yield* evaluators[node.type](node, context) - yield* leave(context) - if (result instanceof Closure) { - Object.defineProperty(getNonEmptyEnv(currentEnvironment(context)).head, uniqueId(context), { - value: result, - writable: false, - enumerable: true - }) - } - return result -} - -export function* apply( - context: Context, - fun: Closure | Value, - args: (Thunk | Value)[], - node: es.CallExpression, - thisContext?: Value -) { - let result: Value - let total = 0 - - while (!(result instanceof ReturnValue)) { - if (fun instanceof Closure) { - checkNumberOfArguments(context, fun, args, node!) - const environment = createEnvironment(context, fun, args, node) - if (result instanceof TailCallReturnValue) { - replaceEnvironment(context, environment) - } else { - pushEnvironment(context, environment) - total++ - } - const bodyEnvironment = createBlockEnvironment(context, 'functionBodyEnvironment') - bodyEnvironment.thisContext = thisContext - pushEnvironment(context, bodyEnvironment) - result = yield* evaluateBlockStatement(context, fun.node.body as es.BlockStatement) - popEnvironment(context) - if (result instanceof TailCallReturnValue) { - fun = result.callee - node = result.node - args = result.args - } else if (!(result instanceof ReturnValue)) { - // No Return Value, set it as undefined - result = new ReturnValue(undefined) - } - } else if (typeof fun === 'function') { - checkNumberOfArguments(context, fun, args, node!) - try { - const forcedArgs = [] - - for (const arg of args) { - forcedArgs.push(yield* forceIt(arg, context)) - } - - result = fun.apply(thisContext, forcedArgs) - break - } catch (e) { - // Recover from exception - context.runtime.environments = context.runtime.environments.slice( - -context.numberOfOuterEnvironments - ) - - const loc = node.loc ?? UNKNOWN_LOCATION - if (!(e instanceof RuntimeSourceError || e instanceof errors.ExceptionError)) { - // The error could've arisen when the builtin called a source function which errored. - // If the cause was a source error, we don't want to include the error. - // However if the error came from the builtin itself, we need to handle it. - return handleRuntimeError(context, new errors.ExceptionError(e, loc)) - } - result = undefined - throw e - } - } else { - return handleRuntimeError(context, new errors.CallingNonFunctionValue(fun, node)) - } - } - // Unwraps return value and release stack environment - if (result instanceof ReturnValue) { - result = result.value - } - for (let i = 1; i <= total; i++) { - popEnvironment(context) - } - return result -} diff --git a/src/modules/loader/__tests__/loader.ts b/src/modules/loader/__tests__/loader.ts index 3bc037315..6ad94fba0 100644 --- a/src/modules/loader/__tests__/loader.ts +++ b/src/modules/loader/__tests__/loader.ts @@ -1,9 +1,9 @@ -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import { Chapter, Variant } from '../../../types' import { ModuleConnectionError, ModuleNotFoundError } from '../../errors' import * as moduleLoader from '../loaders' import type { ModuleDocumentation, ModuleManifest } from '../../moduleTypes' -import { asMockedFunc } from '../../../utils/testing' +import { asMockedFunc } from '../../../utils/testing/misc' const moduleMocker = jest.fn() global.fetch = jest.fn() diff --git a/src/modules/loader/__tests__/requireProvider.ts b/src/modules/loader/__tests__/requireProvider.ts index 3c787e9fd..91e5ad87e 100644 --- a/src/modules/loader/__tests__/requireProvider.ts +++ b/src/modules/loader/__tests__/requireProvider.ts @@ -1,4 +1,4 @@ -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import { Chapter } from '../../../types' import { getRequireProvider } from '../requireProvider' diff --git a/src/modules/preprocessor/__tests__/analyzer.ts b/src/modules/preprocessor/__tests__/analyzer.ts index 522102dd3..80a41ebb8 100644 --- a/src/modules/preprocessor/__tests__/analyzer.ts +++ b/src/modules/preprocessor/__tests__/analyzer.ts @@ -11,7 +11,7 @@ import { stripIndent } from '../../../utils/formatters' import parseProgramsAndConstructImportGraph from '../linker' import analyzeImportsAndExports from '../analyzer' import { parse } from '../../../parser/parser' -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import loadSourceModules from '../../loader' import type { SourceFiles as Files } from '../../moduleTypes' import { objectKeys } from '../../../utils/misc' diff --git a/src/modules/preprocessor/__tests__/linker.ts b/src/modules/preprocessor/__tests__/linker.ts index 4de464c41..0572d94b8 100644 --- a/src/modules/preprocessor/__tests__/linker.ts +++ b/src/modules/preprocessor/__tests__/linker.ts @@ -1,4 +1,4 @@ -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import { MissingSemicolonError } from '../../../parser/errors' import { Chapter, type Context } from '../../../types' import { CircularImportError, ModuleNotFoundError } from '../../errors' @@ -6,6 +6,7 @@ import type { SourceFiles } from '../../moduleTypes' import parseProgramsAndConstructImportGraph from '../linker' import * as resolver from '../resolver' +import { expectTrue } from '../../../utils/testing/misc' jest.spyOn(resolver, 'default') beforeEach(() => { @@ -130,13 +131,8 @@ test('Linker does tree-shaking', async () => { '/a.js' ) - // Wrap to appease typescript - function expectWrapper(cond: boolean): asserts cond { - expect(cond).toEqual(true) - } - expect(errors.length).toEqual(0) - expectWrapper(result.ok) + expectTrue(result.ok) expect(resolver.default).not.toHaveBeenCalledWith('./b.js') expect(Object.keys(result.programs)).not.toContain('/b.js') }) diff --git a/src/modules/preprocessor/__tests__/preprocessor.ts b/src/modules/preprocessor/__tests__/preprocessor.ts index 5f0baa0af..4c5c06d28 100644 --- a/src/modules/preprocessor/__tests__/preprocessor.ts +++ b/src/modules/preprocessor/__tests__/preprocessor.ts @@ -2,11 +2,11 @@ import type { Program } from 'estree' import type { MockedFunction } from 'jest-mock' import { parseError, type IOptions } from '../../..' -import { mockContext } from '../../../mocks/context' +import { mockContext } from '../../../utils/testing/mocks' import { Chapter, type RecursivePartial } from '../../../types' import { memoizedGetModuleDocsAsync } from '../../loader/loaders' import preprocessFileImports from '..' -import { sanitizeAST } from '../../../utils/ast/sanitizer' +import { sanitizeAST } from '../../../utils/testing/sanitizer' import { parse } from '../../../parser/parser' import { accessExportFunctionName, diff --git a/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts b/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts index 8bcc29aa8..1f8dbbb88 100644 --- a/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts +++ b/src/modules/preprocessor/__tests__/transformers/hoistAndMergeImports.ts @@ -1,8 +1,8 @@ -import { mockContext } from '../../../../mocks/context' +import { mockContext } from '../../../../utils/testing/mocks' import { parse } from '../../../../parser/parser' import { Chapter } from '../../../../types' import hoistAndMergeImports from '../../transformers/hoistAndMergeImports' -import { sanitizeAST } from '../../../../utils/ast/sanitizer' +import { sanitizeAST } from '../../../../utils/testing/sanitizer' describe('hoistAndMergeImports', () => { const assertASTsAreEqual = (actualCode: string, expectedCode: string) => { diff --git a/src/modules/preprocessor/__tests__/transformers/removeExports.ts b/src/modules/preprocessor/__tests__/transformers/removeExports.ts index 8e45a5e0e..37f252101 100644 --- a/src/modules/preprocessor/__tests__/transformers/removeExports.ts +++ b/src/modules/preprocessor/__tests__/transformers/removeExports.ts @@ -1,8 +1,8 @@ -import { mockContext } from '../../../../mocks/context' +import { mockContext } from '../../../../utils/testing/mocks' import { parse } from '../../../../parser/parser' import { Chapter, type Context } from '../../../../types' import removeExports from '../../transformers/removeExports' -import { sanitizeAST } from '../../../../utils/ast/sanitizer' +import { sanitizeAST } from '../../../../utils/testing/sanitizer' type TestCase = [description: string, inputCode: string, expectedCode: string] diff --git a/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts b/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts index 5cfb4625a..a5659651b 100644 --- a/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts +++ b/src/modules/preprocessor/__tests__/transformers/transformProgramToFunctionDeclaration.ts @@ -1,9 +1,9 @@ -import { mockContext } from '../../../../mocks/context' +import { mockContext } from '../../../../utils/testing/mocks' import { parse } from '../../../../parser/parser' import { defaultExportLookupName } from '../../../../stdlib/localImport.prelude' import { Chapter } from '../../../../types' import { transformProgramToFunctionDeclaration } from '../../transformers/transformProgramToFunctionDeclaration' -import { sanitizeAST } from '../../../../utils/ast/sanitizer' +import { sanitizeAST } from '../../../../utils/testing/sanitizer' describe('transformImportedFile', () => { const currentFileName = '/dir/a.js' diff --git a/src/name-extractor/__tests__/modules.ts b/src/name-extractor/__tests__/modules.ts index b9c34da82..3337feb0c 100644 --- a/src/name-extractor/__tests__/modules.ts +++ b/src/name-extractor/__tests__/modules.ts @@ -1,13 +1,13 @@ import { DeclarationKind } from '..' import { getNames } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter } from '../../types' import { memoizedGetModuleDocsAsync, memoizedGetModuleManifestAsync } from '../../modules/loader/loaders' -import { asMockedFunc } from '../../utils/testing' +import { asMockedFunc } from '../../utils/testing/misc' import { ModuleConnectionError } from '../../modules/errors' jest.mock('../../modules/loader/loaders') diff --git a/src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap b/src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap index 9f4b9ba4f..74cd75939 100644 --- a/src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap +++ b/src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap @@ -1,4633 +1,419399 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Syntaxes are allowed in the chapter they are introduced 0: parse passes 1`] = ` +exports[`Syntaxes are allowed in the chapter they are introduced 0 1`] = ` Object { - "alertResult": Array [], - "code": "parse(\\"\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - null, - null, + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": null, + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [], + "end": 0, + "loc": SourceLocation { + "end": Position { + "column": 0, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Syntaxes are allowed in the chapter they are introduced 0: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": null, + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [], + "end": 0, + "loc": SourceLocation { + "end": Position { + "column": 0, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": undefined, + }, } `; -exports[`Syntaxes are allowed in the chapter they are introduced 1: parse passes 1`] = ` +exports[`Syntaxes are allowed in the chapter they are introduced 0 2`] = ` Object { - "alertResult": Array [], - "code": "parse(\\"function name(a, b) {\\\\n const sum = a + b;\\\\n if (sum > 1) {\\\\n return sum;\\\\n } else {\\\\n if (a % 2 === 0) {\\\\n return -1;\\\\n } else if (b % 2 === 0) {\\\\n return 1;\\\\n } else {\\\\n return a > b ? 0 : -2;\\\\n }\\\\n }\\\\n}\\\\nname(1, 2);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "function_declaration", - Array [ - Array [ - "name", - Array [ - "name", - null, + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 10, + "expression": Node { + "arguments": Array [ + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"\\"", + "start": 6, + "type": "Literal", + "value": "", + }, ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - Array [ - "name", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "b", - null, - ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "block", - Array [ - Array [ - "sequence", - Array [ - Array [ - Array [ - "constant_declaration", - Array [ - Array [ - "name", - Array [ - "sum", - null, - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "b", - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "conditional_statement", - Array [ - Array [ - "binary_operator_combination", - Array [ - ">", - Array [ - Array [ - "name", - Array [ - "sum", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "name", - Array [ - "sum", - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "conditional_statement", - Array [ - Array [ - "binary_operator_combination", + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 10, + "expression": Node { + "arguments": Array [ + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"\\"", + "start": 6, + "type": "Literal", + "value": "", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + null, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 1 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "name", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 41, + "id": Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "name": "sum", + "start": 30, + "type": "Identifier", + }, + "init": Node { + "end": 41, + "left": Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "name": "a", + "start": 36, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 18, + "line": 2, + }, + }, + "name": "b", + "start": 40, + "type": "Identifier", + }, + "start": 36, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "start": 30, + "type": "VariableDeclarator", + }, + ], + "end": 42, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 24, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "alternate": Node { + "body": Array [ + Node { + "alternate": Node { + "alternate": Node { + "body": Array [ + Node { + "argument": Node { + "alternate": Node { + "argument": Node { + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 26, + "line": 11, + }, + }, + "raw": "2", + "start": 212, + "type": "Literal", + "value": 2, + }, + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 25, + "line": 11, + }, + }, + "operator": "-", + "prefix": true, + "start": 211, + "type": "UnaryExpression", + }, + "consequent": Node { + "end": 208, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 11, + }, + "start": Position { + "column": 21, + "line": 11, + }, + }, + "raw": "0", + "start": 207, + "type": "Literal", + "value": 0, + }, + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "start": 199, + "test": Node { + "end": 204, + "left": Node { + "end": 200, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "name": "a", + "start": 199, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "operator": ">", + "right": Node { + "end": 204, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 11, + }, + "start": Position { + "column": 17, + "line": 11, + }, + }, + "name": "b", + "start": 203, + "type": "Identifier", + }, + "start": 199, + "type": "BinaryExpression", + }, + "type": "ConditionalExpression", + }, + "end": 214, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 11, + }, + "start": Position { + "column": 6, + "line": 11, + }, + }, + "start": 192, + "type": "ReturnStatement", + }, + ], + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 11, + "line": 10, + }, + }, + "start": 184, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "end": 171, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 9, + }, + "start": Position { + "column": 13, + "line": 9, + }, + }, + "raw": "1", + "start": 170, + "type": "Literal", + "value": 1, + }, + "end": 172, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 9, + }, + "start": Position { + "column": 6, + "line": 9, + }, + }, + "start": 163, + "type": "ReturnStatement", + }, + ], + "end": 178, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 10, + }, + "start": Position { + "column": 28, + "line": 8, + }, + }, + "start": 155, + "type": "BlockStatement", + }, + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 11, + "line": 8, + }, + }, + "start": 138, + "test": Node { + "end": 153, + "left": Node { + "end": 147, + "left": Node { + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "name": "b", + "start": 142, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "operator": "%", + "right": Node { + "end": 147, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 8, + }, + "start": Position { + "column": 19, + "line": 8, + }, + }, + "raw": "2", + "start": 146, + "type": "Literal", + "value": 2, + }, + "start": 142, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "operator": "===", + "right": Node { + "end": 153, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 8, + }, + "start": Position { + "column": 25, + "line": 8, + }, + }, + "raw": "0", + "start": 152, + "type": "Literal", + "value": 0, + }, + "start": 142, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "argument": Node { + "end": 125, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 7, + }, + "start": Position { + "column": 14, + "line": 7, + }, + }, + "raw": "1", + "start": 124, + "type": "Literal", + "value": 1, + }, + "end": 125, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 7, + }, + "start": Position { + "column": 13, + "line": 7, + }, + }, + "operator": "-", + "prefix": true, + "start": 123, + "type": "UnaryExpression", + }, + "end": 126, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 7, + }, + "start": Position { + "column": 6, + "line": 7, + }, + }, + "start": 116, + "type": "ReturnStatement", + }, + ], + "end": 132, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 8, + }, + "start": Position { + "column": 21, + "line": 6, + }, + }, + "start": 108, + "type": "BlockStatement", + }, + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "start": 91, + "test": Node { + "end": 106, + "left": Node { + "end": 100, + "left": Node { + "end": 96, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "name": "a", + "start": 95, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "%", + "right": Node { + "end": 100, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 12, + "line": 6, + }, + }, + "raw": "2", + "start": 99, + "type": "Literal", + "value": 2, + }, + "start": 95, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "===", + "right": Node { + "end": 106, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 6, + }, + "start": Position { + "column": 18, + "line": 6, + }, + }, + "raw": "0", + "start": 105, + "type": "Literal", + "value": 0, + }, + "start": 95, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 224, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 13, + }, + "start": Position { + "column": 9, + "line": 5, + }, + }, + "start": 85, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 4, + }, + "start": Position { + "column": 11, + "line": 4, + }, + }, + "name": "sum", + "start": 71, + "type": "Identifier", + }, + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "start": 64, + "type": "ReturnStatement", + }, + ], + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 5, + }, + "start": Position { + "column": 15, + "line": 3, + }, + }, + "start": 58, + "type": "BlockStatement", + }, + "end": 224, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 13, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 45, + "test": Node { + "end": 56, + "left": Node { + "end": 52, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "sum", + "start": 49, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": ">", + "right": Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 3, + }, + "start": Position { + "column": 12, + "line": 3, + }, + }, + "raw": "1", + "start": 55, + "type": "Literal", + "value": 1, + }, + "start": 49, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 226, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 14, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "start": 20, + "type": "BlockStatement", + }, + "end": 226, + "expression": false, + "generator": false, + "id": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "name", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 14, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 14, + "line": 1, + }, + }, + "name": "a", + "start": 14, + "type": "Identifier", + }, + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "name": "b", + "start": 17, + "type": "Identifier", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 238, + "expression": Node { + "arguments": Array [ + Node { + "end": 233, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 15, + }, + "start": Position { + "column": 5, + "line": 15, + }, + }, + "raw": "1", + "start": 232, + "type": "Literal", + "value": 1, + }, + Node { + "end": 236, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 15, + }, + "start": Position { + "column": 8, + "line": 15, + }, + }, + "raw": "2", + "start": 235, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 231, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "name": "name", + "start": 227, + "type": "Identifier", + }, + "end": 237, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "start": 227, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "start": 227, + "type": "ExpressionStatement", + }, + ], + "end": 238, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "function name(a, b) { + const sum = a + b; + if (sum > 1) { + return sum; + } else { + if (a % 2 === 0) { + return -1; + } else if (b % 2 === 0) { + return 1; + } else { + return a > b ? 0 : -2; + } + } +} +name(1, 2);", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "name", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 41, + "id": Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "name": "sum", + "start": 30, + "type": "Identifier", + }, + "init": Node { + "end": 41, + "left": Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "name": "a", + "start": 36, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 18, + "line": 2, + }, + }, + "name": "b", + "start": 40, + "type": "Identifier", + }, + "start": 36, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "start": 30, + "type": "VariableDeclarator", + }, + ], + "end": 42, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 24, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "alternate": Node { + "body": Array [ + Node { + "alternate": Node { + "alternate": Node { + "body": Array [ + Node { + "argument": Node { + "alternate": Node { + "argument": Node { + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 26, + "line": 11, + }, + }, + "raw": "2", + "start": 212, + "type": "Literal", + "value": 2, + }, + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 25, + "line": 11, + }, + }, + "operator": "-", + "prefix": true, + "start": 211, + "type": "UnaryExpression", + }, + "consequent": Node { + "end": 208, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 11, + }, + "start": Position { + "column": 21, + "line": 11, + }, + }, + "raw": "0", + "start": 207, + "type": "Literal", + "value": 0, + }, + "end": 213, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "start": 199, + "test": Node { + "end": 204, + "left": Node { + "end": 200, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "name": "a", + "start": 199, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 11, + }, + "start": Position { + "column": 13, + "line": 11, + }, + }, + "operator": ">", + "right": Node { + "end": 204, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 11, + }, + "start": Position { + "column": 17, + "line": 11, + }, + }, + "name": "b", + "start": 203, + "type": "Identifier", + }, + "start": 199, + "type": "BinaryExpression", + }, + "type": "ConditionalExpression", + }, + "end": 214, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 11, + }, + "start": Position { + "column": 6, + "line": 11, + }, + }, + "start": 192, + "type": "ReturnStatement", + }, + ], + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 11, + "line": 10, + }, + }, + "start": 184, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "end": 171, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 9, + }, + "start": Position { + "column": 13, + "line": 9, + }, + }, + "raw": "1", + "start": 170, + "type": "Literal", + "value": 1, + }, + "end": 172, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 9, + }, + "start": Position { + "column": 6, + "line": 9, + }, + }, + "start": 163, + "type": "ReturnStatement", + }, + ], + "end": 178, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 10, + }, + "start": Position { + "column": 28, + "line": 8, + }, + }, + "start": 155, + "type": "BlockStatement", + }, + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 11, + "line": 8, + }, + }, + "start": 138, + "test": Node { + "end": 153, + "left": Node { + "end": 147, + "left": Node { + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "name": "b", + "start": 142, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "operator": "%", + "right": Node { + "end": 147, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 8, + }, + "start": Position { + "column": 19, + "line": 8, + }, + }, + "raw": "2", + "start": 146, + "type": "Literal", + "value": 2, + }, + "start": 142, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 8, + }, + "start": Position { + "column": 15, + "line": 8, + }, + }, + "operator": "===", + "right": Node { + "end": 153, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 8, + }, + "start": Position { + "column": 25, + "line": 8, + }, + }, + "raw": "0", + "start": 152, + "type": "Literal", + "value": 0, + }, + "start": 142, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "argument": Node { + "end": 125, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 7, + }, + "start": Position { + "column": 14, + "line": 7, + }, + }, + "raw": "1", + "start": 124, + "type": "Literal", + "value": 1, + }, + "end": 125, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 7, + }, + "start": Position { + "column": 13, + "line": 7, + }, + }, + "operator": "-", + "prefix": true, + "start": 123, + "type": "UnaryExpression", + }, + "end": 126, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 7, + }, + "start": Position { + "column": 6, + "line": 7, + }, + }, + "start": 116, + "type": "ReturnStatement", + }, + ], + "end": 132, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 8, + }, + "start": Position { + "column": 21, + "line": 6, + }, + }, + "start": 108, + "type": "BlockStatement", + }, + "end": 220, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 12, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "start": 91, + "test": Node { + "end": 106, + "left": Node { + "end": 100, + "left": Node { + "end": 96, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "name": "a", + "start": 95, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "%", + "right": Node { + "end": 100, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 12, + "line": 6, + }, + }, + "raw": "2", + "start": 99, + "type": "Literal", + "value": 2, + }, + "start": 95, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "===", + "right": Node { + "end": 106, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 6, + }, + "start": Position { + "column": 18, + "line": 6, + }, + }, + "raw": "0", + "start": 105, + "type": "Literal", + "value": 0, + }, + "start": 95, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 224, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 13, + }, + "start": Position { + "column": 9, + "line": 5, + }, + }, + "start": 85, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "argument": Node { + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 4, + }, + "start": Position { + "column": 11, + "line": 4, + }, + }, + "name": "sum", + "start": 71, + "type": "Identifier", + }, + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "start": 64, + "type": "ReturnStatement", + }, + ], + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 5, + }, + "start": Position { + "column": 15, + "line": 3, + }, + }, + "start": 58, + "type": "BlockStatement", + }, + "end": 224, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 13, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 45, + "test": Node { + "end": 56, + "left": Node { + "end": 52, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "sum", + "start": 49, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": ">", + "right": Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 3, + }, + "start": Position { + "column": 12, + "line": 3, + }, + }, + "raw": "1", + "start": 55, + "type": "Literal", + "value": 1, + }, + "start": 49, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 226, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 14, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "start": 20, + "type": "BlockStatement", + }, + "end": 226, + "expression": false, + "generator": false, + "id": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "name", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 14, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 14, + "line": 1, + }, + }, + "name": "a", + "start": 14, + "type": "Identifier", + }, + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "name": "b", + "start": 17, + "type": "Identifier", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 238, + "expression": Node { + "arguments": Array [ + Node { + "end": 233, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 15, + }, + "start": Position { + "column": 5, + "line": 15, + }, + }, + "raw": "1", + "start": 232, + "type": "Literal", + "value": 1, + }, + Node { + "end": 236, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 15, + }, + "start": Position { + "column": 8, + "line": 15, + }, + }, + "raw": "2", + "start": 235, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 231, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "name": "name", + "start": 227, + "type": "Identifier", + }, + "end": 237, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "start": 227, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 15, + }, + }, + "start": 227, + "type": "ExpressionStatement", + }, + ], + "end": 238, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 15, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "function name(a, b) { + const sum = a + b; + if (sum > 1) { + return sum; + } else { + if (a % 2 === 0) { + return -1; + } else if (b % 2 === 0) { + return 1; + } else { + return a > b ? 0 : -2; + } + } +} +name(1, 2);", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 1 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 262, + "expression": Node { + "arguments": Array [ + Node { + "end": 260, + "loc": SourceLocation { + "end": Position { + "column": 260, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function name(a, b) {\\\\n const sum = a + b;\\\\n if (sum > 1) {\\\\n return sum;\\\\n } else {\\\\n if (a % 2 === 0) {\\\\n return -1;\\\\n } else if (b % 2 === 0) {\\\\n return 1;\\\\n } else {\\\\n return a > b ? 0 : -2;\\\\n }\\\\n }\\\\n}\\\\nname(1, 2);\\"", + "start": 6, + "type": "Literal", + "value": "function name(a, b) { + const sum = a + b; + if (sum > 1) { + return sum; + } else { + if (a % 2 === 0) { + return -1; + } else if (b % 2 === 0) { + return 1; + } else { + return a > b ? 0 : -2; + } + } +} +name(1, 2);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 261, + "loc": SourceLocation { + "end": Position { + "column": 261, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 262, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 262, + "loc": SourceLocation { + "end": Position { + "column": 262, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"function name(a, b) {\\\\n const sum = a + b;\\\\n if (sum > 1) {\\\\n return sum;\\\\n } else {\\\\n if (a % 2 === 0) {\\\\n return -1;\\\\n } else if (b % 2 === 0) {\\\\n return 1;\\\\n } else {\\\\n return a > b ? 0 : -2;\\\\n }\\\\n }\\\\n}\\\\nname(1, 2);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 262, + "expression": Node { + "arguments": Array [ + Node { + "end": 260, + "loc": SourceLocation { + "end": Position { + "column": 260, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function name(a, b) {\\\\n const sum = a + b;\\\\n if (sum > 1) {\\\\n return sum;\\\\n } else {\\\\n if (a % 2 === 0) {\\\\n return -1;\\\\n } else if (b % 2 === 0) {\\\\n return 1;\\\\n } else {\\\\n return a > b ? 0 : -2;\\\\n }\\\\n }\\\\n}\\\\nname(1, 2);\\"", + "start": 6, + "type": "Literal", + "value": "function name(a, b) { + const sum = a + b; + if (sum > 1) { + return sum; + } else { + if (a % 2 === 0) { + return -1; + } else if (b % 2 === 0) { + return 1; + } else { + return a > b ? 0 : -2; + } + } +} +name(1, 2);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 261, + "loc": SourceLocation { + "end": Position { + "column": 261, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 262, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 262, + "loc": SourceLocation { + "end": Position { + "column": 262, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"function name(a, b) {\\\\n const sum = a + b;\\\\n if (sum > 1) {\\\\n return sum;\\\\n } else {\\\\n if (a % 2 === 0) {\\\\n return -1;\\\\n } else if (b % 2 === 0) {\\\\n return 1;\\\\n } else {\\\\n return a > b ? 0 : -2;\\\\n }\\\\n }\\\\n}\\\\nname(1, 2);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "function_declaration", + Array [ + Array [ + "name", + Array [ + "name", + null, + ], + ], + Array [ + Array [ + Array [ + "name", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "b", + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "block", + Array [ + Array [ + "sequence", + Array [ + Array [ + Array [ + "constant_declaration", + Array [ + Array [ + "name", + Array [ + "sum", + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "b", + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "conditional_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + ">", + Array [ + Array [ + "name", + Array [ + "sum", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "name", + Array [ + "sum", + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "conditional_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + "===", + Array [ + Array [ + "binary_operator_combination", + Array [ + "%", + Array [ + Array [ + "name", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 0, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "unary_operator_combination", + Array [ + "-unary", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + Array [ + Array [ + "conditional_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + "===", + Array [ + Array [ + "binary_operator_combination", + Array [ + "%", + Array [ + Array [ + "name", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 0, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "conditional_expression", + Array [ + Array [ + "binary_operator_combination", + Array [ + ">", + Array [ + Array [ + "name", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "b", + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 0, + null, + ], + ], + Array [ + Array [ + "unary_operator_combination", + Array [ + "-unary", + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "application", + Array [ + Array [ + "name", + Array [ + "name", + null, + ], + ], + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 2 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [], + "callee": Node { + "body": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "true", + "start": 7, + "type": "Literal", + "value": true, + }, + "end": 11, + "expression": true, + "generator": false, + "id": null, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "params": Array [], + "start": 1, + "type": "ArrowFunctionExpression", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "(() => true)();", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [], + "callee": Node { + "body": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "true", + "start": 7, + "type": "Literal", + "value": true, + }, + "end": 11, + "expression": true, + "generator": false, + "id": null, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "params": Array [], + "start": 1, + "type": "ArrowFunctionExpression", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "(() => true)();", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": true, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 2 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 25, + "expression": Node { + "arguments": Array [ + Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"(() => true)();\\"", + "start": 6, + "type": "Literal", + "value": "(() => true)();", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"(() => true)();\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 25, + "expression": Node { + "arguments": Array [ + Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"(() => true)();\\"", + "start": 6, + "type": "Literal", + "value": "(() => true)();", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"(() => true)();\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "application", + Array [ + Array [ + "lambda_expression", + Array [ + null, + Array [ + Array [ + "return_statement", + Array [ + Array [ + "literal", + Array [ + true, + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + null, + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 3 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 36, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "raw": "1", + "start": 30, + "type": "Literal", + "value": 1, + }, + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 33, + "line": 1, + }, + }, + "raw": "2", + "start": 33, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 25, + "left": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "name": "x", + "start": 20, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "+", + "right": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 24, + "line": 1, + }, + }, + "name": "y", + "start": 24, + "type": "Identifier", + }, + "start": 20, + "type": "BinaryExpression", + }, + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "start": 13, + "type": "ReturnStatement", + }, + ], + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "start": 11, + "type": "BlockStatement", + }, + "end": 28, + "expression": false, + "generator": false, + "id": null, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "x", + "start": 2, + "type": "Identifier", + }, + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "name": "y", + "start": 5, + "type": "Identifier", + }, + ], + "start": 1, + "type": "ArrowFunctionExpression", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "((x, y) => { return x + y; })(1, 2);", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 36, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "raw": "1", + "start": 30, + "type": "Literal", + "value": 1, + }, + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 33, + "line": 1, + }, + }, + "raw": "2", + "start": 33, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 25, + "left": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "name": "x", + "start": 20, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "+", + "right": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 24, + "line": 1, + }, + }, + "name": "y", + "start": 24, + "type": "Identifier", + }, + "start": 20, + "type": "BinaryExpression", + }, + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "start": 13, + "type": "ReturnStatement", + }, + ], + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "start": 11, + "type": "BlockStatement", + }, + "end": 28, + "expression": false, + "generator": false, + "id": null, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "x", + "start": 2, + "type": "Identifier", + }, + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "name": "y", + "start": 5, + "type": "Identifier", + }, + ], + "start": 1, + "type": "ArrowFunctionExpression", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "((x, y) => { return x + y; })(1, 2);", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 3 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 46, + "expression": Node { + "arguments": Array [ + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"((x, y) => { return x + y; })(1, 2);\\"", + "start": 6, + "type": "Literal", + "value": "((x, y) => { return x + y; })(1, 2);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"((x, y) => { return x + y; })(1, 2);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 46, + "expression": Node { + "arguments": Array [ + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"((x, y) => { return x + y; })(1, 2);\\"", + "start": 6, + "type": "Literal", + "value": "((x, y) => { return x + y; })(1, 2);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"((x, y) => { return x + y; })(1, 2);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "application", + Array [ + Array [ + "lambda_expression", + Array [ + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 4 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "true", + "start": 0, + "type": "Literal", + "value": true, + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "true;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "true", + "start": 0, + "type": "Literal", + "value": true, + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "true;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": true, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 4 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"true;\\"", + "start": 6, + "type": "Literal", + "value": "true;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"true;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"true;\\"", + "start": 6, + "type": "Literal", + "value": "true;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"true;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "literal", + Array [ + true, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 5 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 6, + "expression": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "false", + "start": 0, + "type": "Literal", + "value": false, + }, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "false;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 6, + "expression": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "false", + "start": 0, + "type": "Literal", + "value": false, + }, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "false;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": false, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 5 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 16, + "expression": Node { + "arguments": Array [ + Node { + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"false;\\"", + "start": 6, + "type": "Literal", + "value": "false;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"false;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 16, + "expression": Node { + "arguments": Array [ + Node { + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"false;\\"", + "start": 6, + "type": "Literal", + "value": "false;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"false;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "literal", + Array [ + false, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 6 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "directive": "a string \\"\\" \\\\'\\\\'", + "end": 19, + "expression": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "'a string \\"\\" \\\\'\\\\''", + "start": 0, + "type": "Literal", + "value": "a string \\"\\" ''", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "'a string \\"\\" \\\\'\\\\'';", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "directive": "a string \\"\\" \\\\'\\\\'", + "end": 19, + "expression": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "'a string \\"\\" \\\\'\\\\''", + "start": 0, + "type": "Literal", + "value": "a string \\"\\" ''", + }, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "'a string \\"\\" \\\\'\\\\'';", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "a string \\"\\" ''", + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 6 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"'a string \\\\\\"\\\\\\" \\\\\\\\'\\\\\\\\'';\\"", + "start": 6, + "type": "Literal", + "value": "'a string \\"\\" \\\\'\\\\'';", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"'a string \\\\\\"\\\\\\" \\\\\\\\'\\\\\\\\'';\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"'a string \\\\\\"\\\\\\" \\\\\\\\'\\\\\\\\'';\\"", + "start": 6, + "type": "Literal", + "value": "'a string \\"\\" \\\\'\\\\'';", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"'a string \\\\\\"\\\\\\" \\\\\\\\'\\\\\\\\'';\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "literal", + Array [ + "a string \\"\\" ''", + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 7 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "end": 32, + "left": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "31.4", + "start": 0, + "type": "Literal", + "value": 31.4, + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "+", + "right": Node { + "end": 32, + "left": Node { + "end": 26, + "left": Node { + "end": 22, + "left": Node { + "argument": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "3.14e10", + "start": 9, + "type": "Literal", + "value": 31400000000, + }, + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "start": 8, + "type": "UnaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "*", + "right": Node { + "argument": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "start": 20, + "type": "UnaryExpression", + }, + "start": 7, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "%", + "right": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 25, + "line": 1, + }, + }, + "raw": "2", + "start": 25, + "type": "Literal", + "value": 2, + }, + "start": 7, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "/", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 29, + "line": 1, + }, + }, + "raw": "1.5", + "start": 29, + "type": "Literal", + "value": 1.5, + }, + "start": 7, + "type": "BinaryExpression", + }, + "start": 0, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "31.4 + (-3.14e10) * -1 % 2 / 1.5;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "end": 32, + "left": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "31.4", + "start": 0, + "type": "Literal", + "value": 31.4, + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "+", + "right": Node { + "end": 32, + "left": Node { + "end": 26, + "left": Node { + "end": 22, + "left": Node { + "argument": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "3.14e10", + "start": 9, + "type": "Literal", + "value": 31400000000, + }, + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "start": 8, + "type": "UnaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "*", + "right": Node { + "argument": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "-", + "prefix": true, + "start": 20, + "type": "UnaryExpression", + }, + "start": 7, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "%", + "right": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 25, + "line": 1, + }, + }, + "raw": "2", + "start": 25, + "type": "Literal", + "value": 2, + }, + "start": 7, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "operator": "/", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 29, + "line": 1, + }, + }, + "raw": "1.5", + "start": 29, + "type": "Literal", + "value": 1.5, + }, + "start": 7, + "type": "BinaryExpression", + }, + "start": 0, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "31.4 + (-3.14e10) * -1 % 2 / 1.5;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 31.4, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 7 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 43, + "expression": Node { + "arguments": Array [ + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"31.4 + (-3.14e10) * -1 % 2 / 1.5;\\"", + "start": 6, + "type": "Literal", + "value": "31.4 + (-3.14e10) * -1 % 2 / 1.5;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"31.4 + (-3.14e10) * -1 % 2 / 1.5;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 43, + "expression": Node { + "arguments": Array [ + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"31.4 + (-3.14e10) * -1 % 2 / 1.5;\\"", + "start": 6, + "type": "Literal", + "value": "31.4 + (-3.14e10) * -1 % 2 / 1.5;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"31.4 + (-3.14e10) * -1 % 2 / 1.5;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "literal", + Array [ + 31.4, + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "/", + Array [ + Array [ + "binary_operator_combination", + Array [ + "%", + Array [ + Array [ + "binary_operator_combination", + Array [ + "*", + Array [ + Array [ + "unary_operator_combination", + Array [ + "-unary", + Array [ + Array [ + "literal", + Array [ + 31400000000, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "unary_operator_combination", + Array [ + "-unary", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 1.5, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 8 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 55, + "expression": Node { + "end": 54, + "left": Node { + "end": 45, + "left": Node { + "end": 36, + "left": Node { + "end": 26, + "left": Node { + "end": 16, + "left": Node { + "end": 7, + "left": Node { + "end": 1, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "1", + "start": 0, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "===", + "right": Node { + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "1", + "start": 6, + "type": "Literal", + "value": 1, + }, + "start": 0, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 16, + "left": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "1", + "start": 11, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "operator": "<", + "right": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "2", + "start": 15, + "type": "Literal", + "value": 2, + }, + "start": 11, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 26, + "left": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "raw": "1", + "start": 20, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "<=", + "right": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 25, + "line": 1, + }, + }, + "raw": "2", + "start": 25, + "type": "Literal", + "value": 2, + }, + "start": 20, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 36, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "raw": "2", + "start": 30, + "type": "Literal", + "value": 2, + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "operator": ">=", + "right": Node { + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 35, + "line": 1, + }, + }, + "raw": "1", + "start": 35, + "type": "Literal", + "value": 1, + }, + "start": 30, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 45, + "left": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 40, + "line": 1, + }, + }, + "raw": "2", + "start": 40, + "type": "Literal", + "value": 2, + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 40, + "line": 1, + }, + }, + "operator": ">", + "right": Node { + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 44, + "line": 1, + }, + }, + "raw": "1", + "start": 44, + "type": "Literal", + "value": 1, + }, + "start": 40, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "||", + "right": Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 49, + "line": 1, + }, + }, + "raw": "false", + "start": 49, + "type": "Literal", + "value": false, + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 55, + "expression": Node { + "end": 54, + "left": Node { + "end": 45, + "left": Node { + "end": 36, + "left": Node { + "end": 26, + "left": Node { + "end": 16, + "left": Node { + "end": 7, + "left": Node { + "end": 1, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "1", + "start": 0, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "===", + "right": Node { + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "1", + "start": 6, + "type": "Literal", + "value": 1, + }, + "start": 0, + "type": "BinaryExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 16, + "left": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "1", + "start": 11, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "operator": "<", + "right": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "2", + "start": 15, + "type": "Literal", + "value": 2, + }, + "start": 11, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 26, + "left": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "raw": "1", + "start": 20, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "operator": "<=", + "right": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 25, + "line": 1, + }, + }, + "raw": "2", + "start": 25, + "type": "Literal", + "value": 2, + }, + "start": 20, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 36, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "raw": "2", + "start": 30, + "type": "Literal", + "value": 2, + }, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 30, + "line": 1, + }, + }, + "operator": ">=", + "right": Node { + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 35, + "line": 1, + }, + }, + "raw": "1", + "start": 35, + "type": "Literal", + "value": 1, + }, + "start": 30, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "&&", + "right": Node { + "end": 45, + "left": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 40, + "line": 1, + }, + }, + "raw": "2", + "start": 40, + "type": "Literal", + "value": 2, + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 40, + "line": 1, + }, + }, + "operator": ">", + "right": Node { + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 44, + "line": 1, + }, + }, + "raw": "1", + "start": 44, + "type": "Literal", + "value": 1, + }, + "start": 40, + "type": "BinaryExpression", + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "operator": "||", + "right": Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 49, + "line": 1, + }, + }, + "raw": "false", + "start": 49, + "type": "Literal", + "value": false, + }, + "start": 0, + "type": "LogicalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": true, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 8 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 65, + "expression": Node { + "arguments": Array [ + Node { + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;\\"", + "start": 6, + "type": "Literal", + "value": "1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 65, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 65, + "expression": Node { + "arguments": Array [ + Node { + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;\\"", + "start": 6, + "type": "Literal", + "value": "1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 65, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "logical_composition", + Array [ + "||", + Array [ + Array [ + "logical_composition", + Array [ + "&&", + Array [ + Array [ + "logical_composition", + Array [ + "&&", + Array [ + Array [ + "logical_composition", + Array [ + "&&", + Array [ + Array [ + "logical_composition", + Array [ + "&&", + Array [ + Array [ + "binary_operator_combination", + Array [ + "===", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "<", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "<=", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + ">=", + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + ">", + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + false, + null, + ], + ], + null, + ], + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 9 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "alternate": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + "consequent": Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "1", + "start": 7, + "type": "Literal", + "value": 1, + }, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "test": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "true", + "start": 0, + "type": "Literal", + "value": true, + }, + "type": "ConditionalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "true ? 1 : 2;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 1, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set {}, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "alternate": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + "consequent": Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "1", + "start": 7, + "type": "Literal", + "value": 1, + }, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "test": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "true", + "start": 0, + "type": "Literal", + "value": true, + }, + "type": "ConditionalExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "error": [Function], + "get_time": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_number": [Function], + "is_string": [Function], + "is_undefined": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + }, + "typeAliasMap": Map {}, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "true ? 1 : 2;", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 9 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 23, + "expression": Node { + "arguments": Array [ + Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"true ? 1 : 2;\\"", + "start": 6, + "type": "Literal", + "value": "true ? 1 : 2;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"true ? 1 : 2;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 23, + "expression": Node { + "arguments": Array [ + Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"true ? 1 : 2;\\"", + "start": 6, + "type": "Literal", + "value": "true ? 1 : 2;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"true ? 1 : 2;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "conditional_expression", + Array [ + Array [ + "literal", + Array [ + true, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 10 1`] = `"Line 1: null literals are not allowed."`; + +exports[`Syntaxes are allowed in the chapter they are introduced 10 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "null", + "start": 0, + "type": "Literal", + "value": null, + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "null;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "raw": "null", + "start": 0, + "type": "Literal", + "value": null, + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "null;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": null, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 10 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"null;\\"", + "start": 6, + "type": "Literal", + "value": "null;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"null;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"null;\\"", + "start": 6, + "type": "Literal", + "value": "null;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"null;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "literal", + Array [ + null, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 11 1`] = `"Line 1: null literals are not allowed."`; + +exports[`Syntaxes are allowed in the chapter they are introduced 11 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 14, + "expression": Node { + "arguments": Array [ + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "null", + "start": 8, + "type": "Literal", + "value": null, + }, + ], + "callee": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "pair", + "start": 0, + "type": "Identifier", + }, + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "pair(1, null);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 14, + "expression": Node { + "arguments": Array [ + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "null", + "start": 8, + "type": "Literal", + "value": null, + }, + ], + "callee": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "pair", + "start": 0, + "type": "Identifier", + }, + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "pair(1, null);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + 1, + null, + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 11 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 24, + "expression": Node { + "arguments": Array [ + Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"pair(1, null);\\"", + "start": 6, + "type": "Literal", + "value": "pair(1, null);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"pair(1, null);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 24, + "expression": Node { + "arguments": Array [ + Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"pair(1, null);\\"", + "start": 6, + "type": "Literal", + "value": "pair(1, null);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"pair(1, null);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "application", + Array [ + Array [ + "name", + Array [ + "pair", + null, + ], + ], + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + null, + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 12 1`] = `"Line 1: Name list not declared."`; + +exports[`Syntaxes are allowed in the chapter they are introduced 12 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 8, + "expression": Node { + "arguments": Array [ + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + ], + "callee": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "list", + "start": 0, + "type": "Identifier", + }, + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "list(1);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 8, + "expression": Node { + "arguments": Array [ + Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + ], + "callee": Node { + "end": 4, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "list", + "start": 0, + "type": "Identifier", + }, + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "list(1);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + 1, + null, + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 12 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 18, + "expression": Node { + "arguments": Array [ + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"list(1);\\"", + "start": 6, + "type": "Literal", + "value": "list(1);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"list(1);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 18, + "expression": Node { + "arguments": Array [ + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"list(1);\\"", + "start": 6, + "type": "Literal", + "value": "list(1);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"list(1);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "application", + Array [ + Array [ + "name", + Array [ + "list", + null, + ], + ], + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 13 1`] = `"Line 1: Export named declarations are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 13 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 32, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 25, + "type": "ReturnStatement", + }, + ], + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "start": 21, + "type": "BlockStatement", + }, + "end": 36, + "expression": false, + "generator": false, + "id": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "name": "f", + "start": 16, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "name": "x", + "start": 18, + "type": "Identifier", + }, + ], + "start": 7, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 42, + "expression": Node { + "arguments": Array [ + Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "raw": "5", + "start": 39, + "type": "Literal", + "value": 5, + }, + ], + "callee": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 37, + "type": "Identifier", + }, + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 37, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 37, + "type": "ExpressionStatement", + }, + ], + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "export function f(x) { + return x; +} +f(5);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 32, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 25, + "type": "ReturnStatement", + }, + ], + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "start": 21, + "type": "BlockStatement", + }, + "end": 36, + "expression": false, + "generator": false, + "id": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "name": "f", + "start": 16, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "name": "x", + "start": 18, + "type": "Identifier", + }, + ], + "start": 7, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 42, + "expression": Node { + "arguments": Array [ + Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "raw": "5", + "start": 39, + "type": "Literal", + "value": 5, + }, + ], + "callee": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 37, + "type": "Identifier", + }, + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 37, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 37, + "type": "ExpressionStatement", + }, + ], + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "export function f(x) { + return x; +} +f(5);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 5, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 13 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 55, + "expression": Node { + "arguments": Array [ + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\"", + "start": 6, + "type": "Literal", + "value": "export function f(x) { + return x; +} +f(5);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"export function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 55, + "expression": Node { + "arguments": Array [ + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\"", + "start": 6, + "type": "Literal", + "value": "export function f(x) { + return x; +} +f(5);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"export function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "export_named_declaration", + Array [ + Array [ + "function_declaration", + Array [ + Array [ + "name", + Array [ + "f", + null, + ], + ], + Array [ + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + null, + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + Array [ + Array [ + "application", + Array [ + Array [ + "name", + Array [ + "f", + null, + ], + ], + Array [ + Array [ + Array [ + "literal", + Array [ + 5, + null, + ], + ], + null, + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 14 1`] = `"Line 1: Export named declarations are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 14 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 18, + "id": Node { + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "name": "x", + "start": 13, + "type": "Identifier", + }, + "init": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "1", + "start": 17, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "start": 13, + "type": "VariableDeclarator", + }, + ], + "end": 19, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "start": 7, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 22, + "expression": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 20, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 20, + "type": "ExpressionStatement", + }, + ], + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "export const x = 1; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 2, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 18, + "id": Node { + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "name": "x", + "start": 13, + "type": "Identifier", + }, + "init": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "1", + "start": 17, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 13, + "line": 1, + }, + }, + "start": 13, + "type": "VariableDeclarator", + }, + ], + "end": 19, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "start": 7, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 22, + "expression": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 20, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 20, + "type": "ExpressionStatement", + }, + ], + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "export const x = 1; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 14 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export const x = 1;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "export const x = 1; +x;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"export const x = 1;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 33, + "expression": Node { + "arguments": Array [ + Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export const x = 1;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "export const x = 1; +x;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"export const x = 1;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "export_named_declaration", + Array [ + Array [ + "constant_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 15 1`] = ` +"Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 3: Assignment expressions are not allowed +Line 2: While statements are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 15 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [ + Node { + "end": 39, + "expression": Node { + "end": 38, + "left": Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "name": "i", + "start": 29, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "operator": "=", + "right": Node { + "end": 38, + "left": Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "i", + "start": 33, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": "+", + "right": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 10, + "line": 3, + }, + }, + "raw": "1", + "start": 37, + "type": "Literal", + "value": 1, + }, + "start": 33, + "type": "BinaryExpression", + }, + "start": 29, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 29, + "type": "ExpressionStatement", + }, + ], + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "start": 25, + "type": "BlockStatement", + }, + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 23, + "left": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "name": "i", + "start": 18, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 11, + "line": 2, + }, + }, + "raw": "5", + "start": 22, + "type": "Literal", + "value": 5, + }, + "start": 18, + "type": "BinaryExpression", + }, + "type": "WhileStatement", + }, + Node { + "end": 44, + "expression": Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "name": "i", + "start": 42, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "start": 42, + "type": "ExpressionStatement", + }, + ], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +while (i < 5) { + i = i + 1; +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [ + Node { + "end": 39, + "expression": Node { + "end": 38, + "left": Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "name": "i", + "start": 29, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "operator": "=", + "right": Node { + "end": 38, + "left": Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "i", + "start": 33, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": "+", + "right": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 10, + "line": 3, + }, + }, + "raw": "1", + "start": 37, + "type": "Literal", + "value": 1, + }, + "start": 33, + "type": "BinaryExpression", + }, + "start": 29, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 29, + "type": "ExpressionStatement", + }, + ], + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 14, + "line": 2, + }, + }, + "start": 25, + "type": "BlockStatement", + }, + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 23, + "left": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "name": "i", + "start": 18, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 11, + "line": 2, + }, + }, + "raw": "5", + "start": 22, + "type": "Literal", + "value": 5, + }, + "start": 18, + "type": "BinaryExpression", + }, + "type": "WhileStatement", + }, + Node { + "end": 44, + "expression": Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "name": "i", + "start": 42, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "start": 42, + "type": "ExpressionStatement", + }, + ], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +while (i < 5) { + i = i + 1; +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 5, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 15 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 58, + "expression": Node { + "arguments": Array [ + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nwhile (i < 5) {\\\\n i = i + 1;\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +while (i < 5) { + i = i + 1; +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nwhile (i < 5) {\\\\n i = i + 1;\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 58, + "expression": Node { + "arguments": Array [ + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nwhile (i < 5) {\\\\n i = i + 1;\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +while (i < 5) { + i = i + 1; +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nwhile (i < 5) {\\\\n i = i + 1;\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "while_loop", + Array [ + Array [ + "binary_operator_combination", + Array [ + "<", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 5, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 16 1`] = ` +"Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Assignment expressions are not allowed +Line 2: Assignment expressions are not allowed +Line 2: For statements are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 16 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 30, + "line": 2, + }, + }, + "start": 41, + "type": "BlockStatement", + }, + "end": 44, + "init": Node { + "end": 21, + "left": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "name": "i", + "start": 16, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "raw": "1", + "start": 20, + "type": "Literal", + "value": 1, + }, + "start": 16, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 28, + "left": Node { + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "name": "i", + "start": 23, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "raw": "5", + "start": 27, + "type": "Literal", + "value": 5, + }, + "start": 23, + "type": "BinaryExpression", + }, + "type": "ForStatement", + "update": Node { + "end": 39, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 19, + "line": 2, + }, + }, + "name": "i", + "start": 30, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 19, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 39, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "name": "i", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "raw": "1", + "start": 38, + "type": "Literal", + "value": 1, + }, + "start": 34, + "type": "BinaryExpression", + }, + "start": 30, + "type": "AssignmentExpression", + }, + }, + Node { + "end": 47, + "expression": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "i", + "start": 45, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "ExpressionStatement", + }, + ], + "end": 47, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +for (i = 1; i < 5; i = i + 1) { +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 30, + "line": 2, + }, + }, + "start": 41, + "type": "BlockStatement", + }, + "end": 44, + "init": Node { + "end": 21, + "left": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "name": "i", + "start": 16, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "raw": "1", + "start": 20, + "type": "Literal", + "value": 1, + }, + "start": 16, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 28, + "left": Node { + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "name": "i", + "start": 23, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "raw": "5", + "start": 27, + "type": "Literal", + "value": 5, + }, + "start": 23, + "type": "BinaryExpression", + }, + "type": "ForStatement", + "update": Node { + "end": 39, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 19, + "line": 2, + }, + }, + "name": "i", + "start": 30, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 19, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 39, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "name": "i", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "raw": "1", + "start": 38, + "type": "Literal", + "value": 1, + }, + "start": 34, + "type": "BinaryExpression", + }, + "start": 30, + "type": "AssignmentExpression", + }, + }, + Node { + "end": 47, + "expression": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "i", + "start": 45, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "ExpressionStatement", + }, + ], + "end": 47, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +for (i = 1; i < 5; i = i + 1) { +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 5, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 16 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 60, + "expression": Node { + "arguments": Array [ + Node { + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nfor (i = 1; i < 5; i = i + 1) {\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +for (i = 1; i < 5; i = i + 1) { +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nfor (i = 1; i < 5; i = i + 1) {\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 60, + "expression": Node { + "arguments": Array [ + Node { + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nfor (i = 1; i < 5; i = i + 1) {\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +for (i = 1; i < 5; i = i + 1) { +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nfor (i = 1; i < 5; i = i + 1) {\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "for_loop", + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "<", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 5, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "sequence", + Array [ + null, + null, + ], + ], + null, + ], + ], + ], + ], + ], + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 17 1`] = ` +"Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Assignment expressions are not allowed +Line 4: Continue statements are not allowed +Line 6: Assignment expressions are not allowed +Line 8: Break statements are not allowed +Line 7: Missing \\"else\\" in \\"if-else\\" statement. +Line 2: For statements are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 17 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [ + Node { + "alternate": Node { + "body": Array [ + Node { + "end": 101, + "expression": Node { + "end": 100, + "left": Node { + "end": 92, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "name": "i", + "start": 91, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "operator": "=", + "right": Node { + "end": 100, + "left": Node { + "end": 96, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "name": "i", + "start": 95, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "+", + "right": Node { + "end": 100, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 12, + "line": 6, + }, + }, + "raw": "1", + "start": 99, + "type": "Literal", + "value": 1, + }, + "start": 95, + "type": "BinaryExpression", + }, + "start": 91, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "start": 91, + "type": "ExpressionStatement", + }, + Node { + "alternate": null, + "consequent": Node { + "body": Array [ + Node { + "end": 131, + "label": null, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 8, + }, + "start": Position { + "column": 6, + "line": 8, + }, + }, + "start": 125, + "type": "BreakStatement", + }, + ], + "end": 137, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 9, + }, + "start": Position { + "column": 15, + "line": 7, + }, + }, + "start": 117, + "type": "BlockStatement", + }, + "end": 137, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 9, + }, + "start": Position { + "column": 4, + "line": 7, + }, + }, + "start": 106, + "test": Node { + "end": 115, + "left": Node { + "end": 111, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 7, + }, + "start": Position { + "column": 8, + "line": 7, + }, + }, + "name": "j", + "start": 110, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 7, + }, + "start": Position { + "column": 8, + "line": 7, + }, + }, + "operator": ">", + "right": Node { + "end": 115, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 7, + }, + "start": Position { + "column": 12, + "line": 7, + }, + }, + "raw": "2", + "start": 114, + "type": "Literal", + "value": 2, + }, + "start": 110, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 141, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 10, + }, + "start": Position { + "column": 9, + "line": 5, + }, + }, + "start": 85, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "end": 75, + "label": null, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "start": 66, + "type": "ContinueStatement", + }, + ], + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 5, + }, + "start": Position { + "column": 13, + "line": 3, + }, + }, + "start": 60, + "type": "BlockStatement", + }, + "end": 141, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 10, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 49, + "test": Node { + "end": 58, + "left": Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "j", + "start": 53, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": "<", + "right": Node { + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 10, + "line": 3, + }, + }, + "raw": "1", + "start": 57, + "type": "Literal", + "value": 1, + }, + "start": 53, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 11, + }, + "start": Position { + "column": 34, + "line": 2, + }, + }, + "start": 45, + "type": "BlockStatement", + }, + "end": 143, + "init": Node { + "declarations": Array [ + Node { + "end": 25, + "id": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "j", + "start": 20, + "type": "Identifier", + }, + "init": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "raw": "0", + "start": 24, + "type": "Literal", + "value": 0, + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "start": 20, + "type": "VariableDeclarator", + }, + ], + "end": 25, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "start": 16, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 11, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 32, + "left": Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "name": "j", + "start": 27, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 2, + }, + "start": Position { + "column": 20, + "line": 2, + }, + }, + "raw": "5", + "start": 31, + "type": "Literal", + "value": 5, + }, + "start": 27, + "type": "BinaryExpression", + }, + "type": "ForStatement", + "update": Node { + "end": 43, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "name": "j", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 43, + "left": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "name": "j", + "start": 38, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 31, + "line": 2, + }, + }, + "raw": "1", + "start": 42, + "type": "Literal", + "value": 1, + }, + "start": 38, + "type": "BinaryExpression", + }, + "start": 34, + "type": "AssignmentExpression", + }, + }, + Node { + "end": 146, + "expression": Node { + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 12, + }, + }, + "name": "i", + "start": 144, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 12, + }, + }, + "start": 144, + "type": "ExpressionStatement", + }, + ], + "end": 146, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +for (let j = 0; j < 5; j = j + 1) { + if (j < 1) { + continue; + } else { + i = i + 1; + if (j > 2) { + break; + } + } +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "i", + "startTime", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "i", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "1", + "start": 8, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "body": Node { + "body": Array [ + Node { + "alternate": Node { + "body": Array [ + Node { + "end": 101, + "expression": Node { + "end": 100, + "left": Node { + "end": 92, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "name": "i", + "start": 91, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "operator": "=", + "right": Node { + "end": 100, + "left": Node { + "end": 96, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "name": "i", + "start": 95, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 8, + "line": 6, + }, + }, + "operator": "+", + "right": Node { + "end": 100, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 6, + }, + "start": Position { + "column": 12, + "line": 6, + }, + }, + "raw": "1", + "start": 99, + "type": "Literal", + "value": 1, + }, + "start": 95, + "type": "BinaryExpression", + }, + "start": 91, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 6, + }, + "start": Position { + "column": 4, + "line": 6, + }, + }, + "start": 91, + "type": "ExpressionStatement", + }, + Node { + "alternate": null, + "consequent": Node { + "body": Array [ + Node { + "end": 131, + "label": null, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 8, + }, + "start": Position { + "column": 6, + "line": 8, + }, + }, + "start": 125, + "type": "BreakStatement", + }, + ], + "end": 137, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 9, + }, + "start": Position { + "column": 15, + "line": 7, + }, + }, + "start": 117, + "type": "BlockStatement", + }, + "end": 137, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 9, + }, + "start": Position { + "column": 4, + "line": 7, + }, + }, + "start": 106, + "test": Node { + "end": 115, + "left": Node { + "end": 111, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 7, + }, + "start": Position { + "column": 8, + "line": 7, + }, + }, + "name": "j", + "start": 110, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 7, + }, + "start": Position { + "column": 8, + "line": 7, + }, + }, + "operator": ">", + "right": Node { + "end": 115, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 7, + }, + "start": Position { + "column": 12, + "line": 7, + }, + }, + "raw": "2", + "start": 114, + "type": "Literal", + "value": 2, + }, + "start": 110, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 141, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 10, + }, + "start": Position { + "column": 9, + "line": 5, + }, + }, + "start": 85, + "type": "BlockStatement", + }, + "consequent": Node { + "body": Array [ + Node { + "end": 75, + "label": null, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "start": 66, + "type": "ContinueStatement", + }, + ], + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 5, + }, + "start": Position { + "column": 13, + "line": 3, + }, + }, + "start": 60, + "type": "BlockStatement", + }, + "end": 141, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 10, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "start": 49, + "test": Node { + "end": 58, + "left": Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "name": "j", + "start": 53, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 6, + "line": 3, + }, + }, + "operator": "<", + "right": Node { + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 10, + "line": 3, + }, + }, + "raw": "1", + "start": 57, + "type": "Literal", + "value": 1, + }, + "start": 53, + "type": "BinaryExpression", + }, + "type": "IfStatement", + }, + ], + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 11, + }, + "start": Position { + "column": 34, + "line": 2, + }, + }, + "start": 45, + "type": "BlockStatement", + }, + "end": 143, + "init": Node { + "declarations": Array [ + Node { + "end": 25, + "id": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "j", + "start": 20, + "type": "Identifier", + }, + "init": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "raw": "0", + "start": 24, + "type": "Literal", + "value": 0, + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "start": 20, + "type": "VariableDeclarator", + }, + ], + "end": 25, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "start": 16, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 11, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "test": Node { + "end": 32, + "left": Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "name": "j", + "start": 27, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 2, + }, + "start": Position { + "column": 16, + "line": 2, + }, + }, + "operator": "<", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 2, + }, + "start": Position { + "column": 20, + "line": 2, + }, + }, + "raw": "5", + "start": 31, + "type": "Literal", + "value": 5, + }, + "start": 27, + "type": "BinaryExpression", + }, + "type": "ForStatement", + "update": Node { + "end": 43, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "name": "j", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 23, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 43, + "left": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "name": "j", + "start": 38, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 27, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 2, + }, + "start": Position { + "column": 31, + "line": 2, + }, + }, + "raw": "1", + "start": 42, + "type": "Literal", + "value": 1, + }, + "start": 38, + "type": "BinaryExpression", + }, + "start": 34, + "type": "AssignmentExpression", + }, + }, + Node { + "end": 146, + "expression": Node { + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 12, + }, + }, + "name": "i", + "start": 144, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 12, + }, + }, + "start": 144, + "type": "ExpressionStatement", + }, + ], + "end": 146, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 12, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let i = 1; +for (let j = 0; j < 5; j = j + 1) { + if (j < 1) { + continue; + } else { + i = i + 1; + if (j > 2) { + break; + } + } +} +i;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 4, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 17 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 167, + "expression": Node { + "arguments": Array [ + Node { + "end": 165, + "loc": SourceLocation { + "end": Position { + "column": 165, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nfor (let j = 0; j < 5; j = j + 1) {\\\\n if (j < 1) {\\\\n continue;\\\\n } else {\\\\n i = i + 1;\\\\n if (j > 2) {\\\\n break;\\\\n }\\\\n }\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +for (let j = 0; j < 5; j = j + 1) { + if (j < 1) { + continue; + } else { + i = i + 1; + if (j > 2) { + break; + } + } +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 166, + "loc": SourceLocation { + "end": Position { + "column": 166, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 167, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 167, + "loc": SourceLocation { + "end": Position { + "column": 167, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nfor (let j = 0; j < 5; j = j + 1) {\\\\n if (j < 1) {\\\\n continue;\\\\n } else {\\\\n i = i + 1;\\\\n if (j > 2) {\\\\n break;\\\\n }\\\\n }\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 167, + "expression": Node { + "arguments": Array [ + Node { + "end": 165, + "loc": SourceLocation { + "end": Position { + "column": 165, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let i = 1;\\\\nfor (let j = 0; j < 5; j = j + 1) {\\\\n if (j < 1) {\\\\n continue;\\\\n } else {\\\\n i = i + 1;\\\\n if (j > 2) {\\\\n break;\\\\n }\\\\n }\\\\n}\\\\ni;\\"", + "start": 6, + "type": "Literal", + "value": "let i = 1; +for (let j = 0; j < 5; j = j + 1) { + if (j < 1) { + continue; + } else { + i = i + 1; + if (j > 2) { + break; + } + } +} +i;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 166, + "loc": SourceLocation { + "end": Position { + "column": 166, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 167, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 167, + "loc": SourceLocation { + "end": Position { + "column": 167, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let i = 1;\\\\nfor (let j = 0; j < 5; j = j + 1) {\\\\n if (j < 1) {\\\\n continue;\\\\n } else {\\\\n i = i + 1;\\\\n if (j > 2) {\\\\n break;\\\\n }\\\\n }\\\\n}\\\\ni;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "for_loop", + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "j", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 0, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "<", + Array [ + Array [ + "name", + Array [ + "j", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 5, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "j", + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "j", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "conditional_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + "<", + Array [ + Array [ + "name", + Array [ + "j", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "continue_statement", + null, + ], + Array [ + Array [ + "sequence", + Array [ + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", Array [ - "===", + "i", + null, + ], + ], + Array [ + Array [ + "binary_operator_combination", Array [ - Array [ - "binary_operator_combination", - Array [ - "%", - Array [ - Array [ - "name", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], + "+", Array [ Array [ - "literal", + "name", Array [ - 0, + "i", null, ], ], - null, - ], - ], - ], - ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "unary_operator_combination", Array [ - "-unary", Array [ + "literal", Array [ - "literal", - Array [ - 1, - null, - ], + 1, + null, ], - null, ], + null, ], ], - null, ], ], + null, + ], + ], + ], + Array [ + Array [ + "conditional_statement", + Array [ Array [ + "binary_operator_combination", Array [ - "conditional_statement", + ">", Array [ Array [ - "binary_operator_combination", - Array [ - "===", - Array [ - Array [ - "binary_operator_combination", - Array [ - "%", - Array [ - Array [ - "name", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - 0, - null, - ], - ], - null, - ], - ], + "name", + Array [ + "j", + null, ], ], Array [ Array [ - "return_statement", + "literal", Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], + 2, null, ], ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "conditional_expression", - Array [ - Array [ - "binary_operator_combination", - Array [ - ">", - Array [ - Array [ - "name", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "b", - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - 0, - null, - ], - ], - Array [ - Array [ - "unary_operator_combination", - Array [ - "-unary", - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - null, - ], + null, ], ], ], - null, + ], + Array [ + Array [ + "break_statement", + null, + ], + Array [ + Array [ + "sequence", + Array [ + null, + null, + ], + ], + null, + ], ], ], ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + ], + ], + ], + Array [ + Array [ + "name", + Array [ + "i", + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 18 1`] = `"Line 1: Array expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 18 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 3, + "expression": Node { + "elements": Array [], + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 3, + "expression": Node { + "elements": Array [], + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 18 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "arguments": Array [ + Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[];\\"", + "start": 6, + "type": "Literal", + "value": "[];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "arguments": Array [ + Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[];\\"", + "start": 6, + "type": "Literal", + "value": "[];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "array_expression", + Array [ + null, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 19 1`] = `"Line 1: Array expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 19 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 10, + "expression": Node { + "elements": Array [ + Node { + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "raw": "1", + "start": 1, + "type": "Literal", + "value": 1, + }, + Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "raw": "2", + "start": 4, + "type": "Literal", + "value": 2, + }, + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "3", + "start": 7, + "type": "Literal", + "value": 3, + }, + ], + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[1, 2, 3];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 10, + "expression": Node { + "elements": Array [ + Node { + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "raw": "1", + "start": 1, + "type": "Literal", + "value": 1, + }, + Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "raw": "2", + "start": 4, + "type": "Literal", + "value": 2, + }, + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "3", + "start": 7, + "type": "Literal", + "value": 3, + }, + ], + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[1, 2, 3];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + 1, + 2, + 3, + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 19 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "arguments": Array [ + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[1, 2, 3];\\"", + "start": 6, + "type": "Literal", + "value": "[1, 2, 3];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[1, 2, 3];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "arguments": Array [ + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[1, 2, 3];\\"", + "start": 6, + "type": "Literal", + "value": "[1, 2, 3];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[1, 2, 3];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "array_expression", + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 20 1`] = ` +"Line 1: Array expressions are not allowed +Line 1: Member expressions are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 20 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "computed": true, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "elements": Array [ + Node { + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "raw": "1", + "start": 1, + "type": "Literal", + "value": 1, + }, + Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "raw": "2", + "start": 4, + "type": "Literal", + "value": 2, + }, + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "3", + "start": 7, + "type": "Literal", + "value": 3, + }, + ], + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "property": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "1", + "start": 10, + "type": "Literal", + "value": 1, + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[1, 2, 3][1];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 13, + "expression": Node { + "computed": true, + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "elements": Array [ + Node { + "end": 2, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "raw": "1", + "start": 1, + "type": "Literal", + "value": 1, + }, + Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "raw": "2", + "start": 4, + "type": "Literal", + "value": 2, + }, + Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "3", + "start": 7, + "type": "Literal", + "value": 3, + }, + ], + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ArrayExpression", + }, + "property": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "1", + "start": 10, + "type": "Literal", + "value": 1, + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "[1, 2, 3][1];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 2, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 20 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 23, + "expression": Node { + "arguments": Array [ + Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[1, 2, 3][1];\\"", + "start": 6, + "type": "Literal", + "value": "[1, 2, 3][1];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[1, 2, 3][1];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 23, + "expression": Node { + "arguments": Array [ + Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"[1, 2, 3][1];\\"", + "start": 6, + "type": "Literal", + "value": "[1, 2, 3][1];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 22, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"[1, 2, 3][1];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_access", + Array [ + Array [ + "array_expression", + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 21 1`] = ` +"Line 1: Array expressions are not allowed +Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Member expressions are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 21 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 17, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "elements": Array [ + Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "1", + "start": 9, + "type": "Literal", + "value": 1, + }, + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "2", + "start": 12, + "type": "Literal", + "value": 2, + }, + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "3", + "start": 15, + "type": "Literal", + "value": 3, + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "start": 8, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 18, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 24, + "expression": Node { + "computed": true, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 19, + "type": "Identifier", + }, + "property": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "start": 19, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 19, + "type": "ExpressionStatement", + }, + ], + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = [1, 2, 3]; +x[1];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 17, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "elements": Array [ + Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "1", + "start": 9, + "type": "Literal", + "value": 1, + }, + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "2", + "start": 12, + "type": "Literal", + "value": 2, + }, + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "3", + "start": 15, + "type": "Literal", + "value": 3, + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "start": 8, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 18, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 24, + "expression": Node { + "computed": true, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 19, + "type": "Identifier", + }, + "property": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "start": 19, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 19, + "type": "ExpressionStatement", + }, + ], + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = [1, 2, 3]; +x[1];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 2, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 21 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 35, + "expression": Node { + "arguments": Array [ + Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = [1, 2, 3];\\\\nx[1];\\"", + "start": 6, + "type": "Literal", + "value": "let x = [1, 2, 3]; +x[1];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = [1, 2, 3];\\\\nx[1];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 35, + "expression": Node { + "arguments": Array [ + Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = [1, 2, 3];\\\\nx[1];\\"", + "start": 6, + "type": "Literal", + "value": "let x = [1, 2, 3]; +x[1];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = [1, 2, 3];\\\\nx[1];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "array_expression", + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_access", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 22 1`] = ` +"Line 1: Array expressions are not allowed +Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Member expressions are not allowed +Line 2: Assignment expressions are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 22 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 17, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "elements": Array [ + Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "1", + "start": 9, + "type": "Literal", + "value": 1, + }, + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "2", + "start": 12, + "type": "Literal", + "value": 2, + }, + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "3", + "start": 15, + "type": "Literal", + "value": 3, + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "start": 8, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 18, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 28, + "expression": Node { + "end": 27, + "left": Node { + "computed": true, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 19, + "type": "Identifier", + }, + "property": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "start": 19, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "raw": "4", + "start": 26, + "type": "Literal", + "value": 4, + }, + "start": 19, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 19, + "type": "ExpressionStatement", + }, + ], + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = [1, 2, 3]; +x[1] = 4;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 17, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "elements": Array [ + Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "raw": "1", + "start": 9, + "type": "Literal", + "value": 1, + }, + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "2", + "start": 12, + "type": "Literal", + "value": 2, + }, + Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "3", + "start": 15, + "type": "Literal", + "value": 3, + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "start": 8, + "type": "ArrayExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 18, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 28, + "expression": Node { + "end": 27, + "left": Node { + "computed": true, + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 19, + "type": "Identifier", + }, + "property": Node { + "end": 22, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "1", + "start": 21, + "type": "Literal", + "value": 1, + }, + "start": 19, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 7, + "line": 2, + }, + }, + "raw": "4", + "start": 26, + "type": "Literal", + "value": 4, + }, + "start": 19, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 19, + "type": "ExpressionStatement", + }, + ], + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = [1, 2, 3]; +x[1] = 4;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 4, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 22 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 39, + "expression": Node { + "arguments": Array [ + Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = [1, 2, 3];\\\\nx[1] = 4;\\"", + "start": 6, + "type": "Literal", + "value": "let x = [1, 2, 3]; +x[1] = 4;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 38, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = [1, 2, 3];\\\\nx[1] = 4;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 39, + "expression": Node { + "arguments": Array [ + Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = [1, 2, 3];\\\\nx[1] = 4;\\"", + "start": 6, + "type": "Literal", + "value": "let x = [1, 2, 3]; +x[1] = 4;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 38, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = [1, 2, 3];\\\\nx[1] = 4;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "array_expression", + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_assignment", + Array [ + Array [ + "object_access", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 4, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 23 1`] = ` +"Line 1: Mutable variable declaration using keyword 'let' is not allowed. +Line 2: Mutable variable declaration using keyword 'let' is not allowed. +Line 3: Mutable variable declaration using keyword 'let' is not allowed. +Line 4: Assignment expressions are not allowed +Line 4: Assignment expressions are not allowed +Line 4: Assignment expressions are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 23 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + "y", + "z", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "3", + "start": 8, + "type": "Literal", + "value": 3, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 4, + "line": 2, + }, + }, + "name": "y", + "start": 15, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "raw": "4", + "start": 19, + "type": "Literal", + "value": 4, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 4, + "line": 2, + }, + }, + "start": 15, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 31, + "id": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 3, + }, + "start": Position { + "column": 4, + "line": 3, + }, + }, + "name": "z", + "start": 26, + "type": "Identifier", + }, + "init": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 8, + "line": 3, + }, + }, + "raw": "5", + "start": 30, + "type": "Literal", + "value": 5, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 4, + "line": 3, + }, + }, + "start": 26, + "type": "VariableDeclarator", + }, + ], + "end": 32, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 22, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 47, + "expression": Node { + "end": 46, + "left": Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "x", + "start": 33, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "left": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "name": "y", + "start": 37, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "left": Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 4, + }, + "start": Position { + "column": 8, + "line": 4, + }, + }, + "name": "z", + "start": 41, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 8, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 12, + "line": 4, + }, + }, + "raw": "6", + "start": 45, + "type": "Literal", + "value": 6, + }, + "start": 41, + "type": "AssignmentExpression", + }, + "start": 37, + "type": "AssignmentExpression", + }, + "start": 33, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 33, + "type": "ExpressionStatement", + }, + Node { + "end": 50, + "expression": Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "name": "x", + "start": 48, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "start": 48, + "type": "ExpressionStatement", + }, + ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = 3; +let y = 4; +let z = 5; +x = y = z = 6; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + "y", + "z", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 9, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "3", + "start": 8, + "type": "Literal", + "value": 3, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 10, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 4, + "line": 2, + }, + }, + "name": "y", + "start": 15, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "raw": "4", + "start": 19, + "type": "Literal", + "value": 4, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 4, + "line": 2, + }, + }, + "start": 15, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 11, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 31, + "id": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 3, + }, + "start": Position { + "column": 4, + "line": 3, + }, + }, + "name": "z", + "start": 26, + "type": "Identifier", + }, + "init": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 8, + "line": 3, + }, + }, + "raw": "5", + "start": 30, + "type": "Literal", + "value": 5, + }, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 3, + }, + "start": Position { + "column": 4, + "line": 3, + }, + }, + "start": 26, + "type": "VariableDeclarator", + }, + ], + "end": 32, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 22, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 47, + "expression": Node { + "end": 46, + "left": Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "x", + "start": 33, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "left": Node { + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "name": "y", + "start": 37, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 4, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "left": Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 4, + }, + "start": Position { + "column": 8, + "line": 4, + }, + }, + "name": "z", + "start": 41, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 8, + "line": 4, + }, + }, + "operator": "=", + "right": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 12, + "line": 4, + }, + }, + "raw": "6", + "start": 45, + "type": "Literal", + "value": 6, + }, + "start": 41, + "type": "AssignmentExpression", + }, + "start": 37, + "type": "AssignmentExpression", + }, + "start": 33, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 33, + "type": "ExpressionStatement", + }, + Node { + "end": 50, + "expression": Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "name": "x", + "start": 48, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 5, + }, + }, + "start": 48, + "type": "ExpressionStatement", + }, + ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 5, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = 3; +let y = 4; +let z = 5; +x = y = z = 6; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 6, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 23 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 64, + "expression": Node { + "arguments": Array [ + Node { + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = 3;\\\\nlet y = 4;\\\\nlet z = 5;\\\\nx = y = z = 6;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "let x = 3; +let y = 4; +let z = 5; +x = y = z = 6; +x;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = 3;\\\\nlet y = 4;\\\\nlet z = 5;\\\\nx = y = z = 6;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 64, + "expression": Node { + "arguments": Array [ + Node { + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = 3;\\\\nlet y = 4;\\\\nlet z = 5;\\\\nx = y = z = 6;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "let x = 3; +let y = 4; +let z = 5; +x = y = z = 6; +x;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = 3;\\\\nlet y = 4;\\\\nlet z = 5;\\\\nx = y = z = 6;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 4, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "z", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 5, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + Array [ + Array [ + "assignment", + Array [ + Array [ + "name", + Array [ + "z", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 6, + null, ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + null, + ], + ], + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 24 1`] = ` +"Line 1: Rest elements are not allowed +Line 4: Array expressions are not allowed +Line 4: Spread elements are not allowed" +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 24 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 39, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "name": "y", + "start": 38, + "type": "Identifier", + }, + "start": 34, + "type": "BinaryExpression", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 27, + "type": "ReturnStatement", + }, + ], + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 23, + "line": 1, + }, + }, + "start": 23, + "type": "BlockStatement", + }, + "end": 42, + "expression": false, + "generator": false, + "id": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "f", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "name": "x", + "start": 11, + "type": "Identifier", + }, + Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 14, + "line": 1, + }, + }, + "name": "y", + "start": 14, + "type": "Identifier", + }, + Node { + "argument": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "start": 20, + "type": "Identifier", + }, + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "start": 17, + "type": "RestElement", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 56, + "expression": Node { + "arguments": Array [ + Node { + "argument": Node { + "elements": Array [ + Node { + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 4, + }, + "start": Position { + "column": 6, + "line": 4, + }, + }, + "raw": "1", + "start": 49, + "type": "Literal", + "value": 1, + }, + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 4, + }, + "start": Position { + "column": 9, + "line": 4, + }, + }, + "raw": "2", + "start": 52, + "type": "Literal", + "value": 2, + }, + ], + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 4, + }, + "start": Position { + "column": 5, + "line": 4, + }, + }, + "start": 48, + "type": "ArrayExpression", + }, + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "start": 45, + "type": "SpreadElement", + }, + ], + "callee": Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 43, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 43, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 43, + "type": "ExpressionStatement", + }, + ], + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "function f(x, y, ...z) { + return x + y; +} +f(...[1, 2]);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 3, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 39, + "left": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 34, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "operator": "+", + "right": Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "name": "y", + "start": 38, + "type": "Identifier", + }, + "start": 34, + "type": "BinaryExpression", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 27, + "type": "ReturnStatement", + }, + ], + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 23, + "line": 1, + }, + }, + "start": 23, + "type": "BlockStatement", + }, + "end": 42, + "expression": false, + "generator": false, + "id": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "f", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "name": "x", + "start": 11, + "type": "Identifier", + }, + Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 14, + "line": 1, + }, + }, + "name": "y", + "start": 14, + "type": "Identifier", + }, + Node { + "argument": Node { + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 20, + "line": 1, + }, + }, + "name": "z", + "start": 20, + "type": "Identifier", + }, + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "start": 17, + "type": "RestElement", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 56, + "expression": Node { + "arguments": Array [ + Node { + "argument": Node { + "elements": Array [ + Node { + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 4, + }, + "start": Position { + "column": 6, + "line": 4, + }, + }, + "raw": "1", + "start": 49, + "type": "Literal", + "value": 1, + }, + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 4, + }, + "start": Position { + "column": 9, + "line": 4, + }, + }, + "raw": "2", + "start": 52, + "type": "Literal", + "value": 2, + }, + ], + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 4, + }, + "start": Position { + "column": 5, + "line": 4, + }, + }, + "start": 48, + "type": "ArrayExpression", + }, + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "start": 45, + "type": "SpreadElement", + }, + ], + "callee": Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 43, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 43, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 43, + "type": "ExpressionStatement", + }, + ], + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "arity": [Function], + "array_length": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "function f(x, y, ...z) { + return x + y; +} +f(...[1, 2]);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 24 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 69, + "expression": Node { + "arguments": Array [ + Node { + "end": 67, + "loc": SourceLocation { + "end": Position { + "column": 67, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function f(x, y, ...z) {\\\\n return x + y;\\\\n}\\\\nf(...[1, 2]);\\"", + "start": 6, + "type": "Literal", + "value": "function f(x, y, ...z) { + return x + y; +} +f(...[1, 2]);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 68, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"function f(x, y, ...z) {\\\\n return x + y;\\\\n}\\\\nf(...[1, 2]);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 69, + "expression": Node { + "arguments": Array [ + Node { + "end": 67, + "loc": SourceLocation { + "end": Position { + "column": 67, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function f(x, y, ...z) {\\\\n return x + y;\\\\n}\\\\nf(...[1, 2]);\\"", + "start": 6, + "type": "Literal", + "value": "function f(x, y, ...z) { + return x + y; +} +f(...[1, 2]);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 68, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"function f(x, y, ...z) {\\\\n return x + y;\\\\n}\\\\nf(...[1, 2]);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "function_declaration", + Array [ + Array [ + "name", + Array [ + "f", + null, + ], + ], + Array [ + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + Array [ + Array [ + "rest_element", + Array [ + Array [ + "name", + Array [ + "z", + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "return_statement", + Array [ + Array [ + "binary_operator_combination", + Array [ + "+", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "y", + null, + ], + ], + null, + ], + ], + ], + ], + null, + ], + ], + null, + ], + ], + ], + ], + Array [ + Array [ + "application", + Array [ + Array [ + "name", + Array [ + "f", + null, + ], + ], + Array [ + Array [ + Array [ + "spread_element", + Array [ + Array [ + "array_expression", + Array [ + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, null, ], ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 25 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 25 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [], + "start": 1, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({});", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 5, + "expression": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [], + "start": 1, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({});", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Object {}, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 25 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({});\\"", + "start": 6, + "type": "Literal", + "value": "({});", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({});\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "arguments": Array [ + Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({});\\"", + "start": 6, + "type": "Literal", + "value": "({});", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 14, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({});\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_expression", + Array [ + null, + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 26 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 26 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2});", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 15, + "expression": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2});", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Object { + "a": 1, + "b": 2, + }, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 26 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 25, + "expression": Node { + "arguments": Array [ + Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2});\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2});", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2});\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 25, + "expression": Node { + "arguments": Array [ + Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 23, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2});\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2});", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 24, + "loc": SourceLocation { + "end": Position { + "column": 24, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2});\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 27 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 27 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "computed": true, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "'a'", + "start": 15, + "type": "Literal", + "value": "a", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2})['a'];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "computed": true, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "'a'", + "start": 15, + "type": "Literal", + "value": "a", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2})['a'];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 27 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 30, + "expression": Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2})['a'];\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2})['a'];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2})['a'];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 30, + "expression": Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2})['a'];\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2})['a'];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2})['a'];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_access", + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 28 1`] = ` +"Line 1: Object expressions are not allowed +Line 1: Dot abbreviations are not allowed." +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 28 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 17, + "expression": Node { + "computed": false, + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "a", + "start": 15, + "type": "Identifier", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2}).a;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 17, + "expression": Node { + "computed": false, + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "name": "a", + "start": 2, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "name": "b", + "start": 8, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "a", + "start": 15, + "type": "Identifier", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({a: 1, b: 2}).a;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 28 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 27, + "expression": Node { + "arguments": Array [ + Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2}).a;\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2}).a;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2}).a;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 27, + "expression": Node { + "arguments": Array [ + Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({a: 1, b: 2}).a;\\"", + "start": 6, + "type": "Literal", + "value": "({a: 1, b: 2}).a;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 26, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({a: 1, b: 2}).a;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_access", + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 29 1`] = ` +"Line 1: Object expressions are not allowed +Line 1: Dot abbreviations are not allowed." +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 29 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 21, + "expression": Node { + "computed": false, + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 8, + "key": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "raw": "'a'", + "start": 2, + "type": "Literal", + "value": "a", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "1", + "start": 7, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 16, + "key": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "'b'", + "start": 10, + "type": "Literal", + "value": "b", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 10, + "type": "Property", + "value": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "2", + "start": 15, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 19, + "line": 1, + }, + }, + "name": "a", + "start": 19, + "type": "Identifier", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({'a': 1, 'b': 2}).a;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 21, + "expression": Node { + "computed": false, + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 8, + "key": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "raw": "'a'", + "start": 2, + "type": "Literal", + "value": "a", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 8, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 1, + }, + "start": Position { + "column": 7, + "line": 1, + }, + }, + "raw": "1", + "start": 7, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 16, + "key": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "'b'", + "start": 10, + "type": "Literal", + "value": "b", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 10, + "type": "Property", + "value": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "2", + "start": 15, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 19, + "line": 1, + }, + }, + "name": "a", + "start": 19, + "type": "Identifier", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({'a': 1, 'b': 2}).a;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 29 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 31, + "expression": Node { + "arguments": Array [ + Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({'a': 1, 'b': 2}).a;\\"", + "start": 6, + "type": "Literal", + "value": "({'a': 1, 'b': 2}).a;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({'a': 1, 'b': 2}).a;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 31, + "expression": Node { + "arguments": Array [ + Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({'a': 1, 'b': 2}).a;\\"", + "start": 6, + "type": "Literal", + "value": "({'a': 1, 'b': 2}).a;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 31, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({'a': 1, 'b': 2}).a;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_access", + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "literal", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "literal", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 30 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 30 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "computed": true, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "raw": "1", + "start": 2, + "type": "Literal", + "value": 1, + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "2", + "start": 8, + "type": "Literal", + "value": 2, + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "'1'", + "start": 15, + "type": "Literal", + "value": "1", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({1: 1, 2: 2})['1'];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 20, + "expression": Node { + "computed": true, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "object": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 1, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 6, + "key": Node { + "end": 3, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "raw": "1", + "start": 2, + "type": "Literal", + "value": 1, + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 2, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 2, + "type": "Property", + "value": Node { + "end": 6, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 1, + }, + "start": Position { + "column": 5, + "line": 1, + }, + }, + "raw": "1", + "start": 5, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 12, + "key": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "raw": "2", + "start": 8, + "type": "Literal", + "value": 2, + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 8, + "type": "Property", + "value": Node { + "end": 12, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 11, + "line": 1, + }, + }, + "raw": "2", + "start": 11, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 1, + "type": "ObjectExpression", + }, + "property": Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "raw": "'1'", + "start": 15, + "type": "Literal", + "value": "1", + }, + "start": 0, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "({1: 1, 2: 2})['1'];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 30 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 30, + "expression": Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({1: 1, 2: 2})['1'];\\"", + "start": 6, + "type": "Literal", + "value": "({1: 1, 2: 2})['1'];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({1: 1, 2: 2})['1'];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 30, + "expression": Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"({1: 1, 2: 2})['1'];\\"", + "start": 6, + "type": "Literal", + "value": "({1: 1, 2: 2})['1'];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"({1: 1, 2: 2})['1'];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "object_access", + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + "1", + null, + ], + ], + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 31 1`] = `"Line 2: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 31 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "key", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 15, + "id": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "name": "key", + "start": 6, + "type": "Identifier", + }, + "init": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "'a'", + "start": 12, + "type": "Literal", + "value": "a", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "start": 6, + "type": "VariableDeclarator", + }, + ], + "end": 16, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 37, + "expression": Node { + "computed": true, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 2, + }, + "start": Position { + "column": 1, + "line": 2, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 23, + "key": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "name": "a", + "start": 19, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "method": false, + "shorthand": false, + "start": 19, + "type": "Property", + "value": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "raw": "1", + "start": 22, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 29, + "key": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "name": "b", + "start": 25, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "method": false, + "shorthand": false, + "start": 25, + "type": "Property", + "value": Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 11, + "line": 2, + }, + }, + "raw": "2", + "start": 28, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 18, + "type": "ObjectExpression", + }, + "property": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 2, + }, + "start": Position { + "column": 15, + "line": 2, + }, + }, + "name": "key", + "start": 32, + "type": "Identifier", + }, + "start": 17, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 17, + "type": "ExpressionStatement", + }, + ], + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "const key = 'a'; +({a: 1, b: 2})[key];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "key", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 15, + "id": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "name": "key", + "start": 6, + "type": "Identifier", + }, + "init": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "'a'", + "start": 12, + "type": "Literal", + "value": "a", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "start": 6, + "type": "VariableDeclarator", + }, + ], + "end": 16, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 37, + "expression": Node { + "computed": true, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 2, + }, + "start": Position { + "column": 1, + "line": 2, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 23, + "key": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "name": "a", + "start": 19, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "method": false, + "shorthand": false, + "start": 19, + "type": "Property", + "value": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 5, + "line": 2, + }, + }, + "raw": "1", + "start": 22, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 29, + "key": Node { + "end": 26, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "name": "b", + "start": 25, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 8, + "line": 2, + }, + }, + "method": false, + "shorthand": false, + "start": 25, + "type": "Property", + "value": Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 2, + }, + "start": Position { + "column": 11, + "line": 2, + }, + }, + "raw": "2", + "start": 28, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 18, + "type": "ObjectExpression", + }, + "property": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 2, + }, + "start": Position { + "column": 15, + "line": 2, + }, + }, + "name": "key", + "start": 32, + "type": "Identifier", + }, + "start": 17, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 17, + "type": "ExpressionStatement", + }, + ], + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "const key = 'a'; +({a: 1, b: 2})[key];", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 31 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 48, + "expression": Node { + "arguments": Array [ + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"const key = 'a';\\\\n({a: 1, b: 2})[key];\\"", + "start": 6, + "type": "Literal", + "value": "const key = 'a'; +({a: 1, b: 2})[key];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 47, + "loc": SourceLocation { + "end": Position { + "column": 47, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"const key = 'a';\\\\n({a: 1, b: 2})[key];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 48, + "expression": Node { + "arguments": Array [ + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"const key = 'a';\\\\n({a: 1, b: 2})[key];\\"", + "start": 6, + "type": "Literal", + "value": "const key = 'a'; +({a: 1, b: 2})[key];", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 47, + "loc": SourceLocation { + "end": Position { + "column": 47, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"const key = 'a';\\\\n({a: 1, b: 2})[key];\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "constant_declaration", + Array [ + Array [ + "name", + Array [ + "key", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_access", + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "key", + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 32 1`] = ` +"Line 1: Object expressions are not allowed +Line 2: Dot abbreviations are not allowed." +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 32 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 30, + "expression": Node { + "end": 29, + "left": Node { + "computed": false, + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 22, + "type": "Identifier", + }, + "property": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "name": "a", + "start": 24, + "type": "Identifier", + }, + "start": 22, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "raw": "3", + "start": 28, + "type": "Literal", + "value": 3, + }, + "start": 22, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +x.a = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 30, + "expression": Node { + "end": 29, + "left": Node { + "computed": false, + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 22, + "type": "Identifier", + }, + "property": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "name": "a", + "start": 24, + "type": "Identifier", + }, + "start": 22, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "raw": "3", + "start": 28, + "type": "Literal", + "value": 3, + }, + "start": 22, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "type": "ExpressionStatement", + }, + ], + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 8, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +x.a = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 32 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 41, + "expression": Node { + "arguments": Array [ + Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nx.a = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +x.a = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nx.a = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 41, + "expression": Node { + "arguments": Array [ + Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nx.a = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +x.a = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nx.a = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_assignment", + Array [ + Array [ + "object_access", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 33 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 33 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 33, + "expression": Node { + "end": 32, + "left": Node { + "computed": true, + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 22, + "type": "Identifier", + }, + "property": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "'a'", + "start": 24, + "type": "Literal", + "value": "a", + }, + "start": 22, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "raw": "3", + "start": 31, + "type": "Literal", + "value": 3, + }, + "start": 22, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +x['a'] = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 33, + "expression": Node { + "end": 32, + "left": Node { + "computed": true, + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "object": Node { + "end": 23, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "name": "x", + "start": 22, + "type": "Identifier", + }, + "property": Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "raw": "'a'", + "start": 24, + "type": "Literal", + "value": "a", + }, + "start": 22, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "operator": "=", + "right": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "raw": "3", + "start": 31, + "type": "Literal", + "value": 3, + }, + "start": 22, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +x['a'] = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 33 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 44, + "expression": Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nx['a'] = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +x['a'] = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nx['a'] = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 44, + "expression": Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nx['a'] = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +x['a'] = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nx['a'] = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_assignment", + Array [ + Array [ + "object_access", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 34 1`] = `"Line 1: Object expressions are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 34 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + "key", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 37, + "id": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "name": "key", + "start": 28, + "type": "Identifier", + }, + "init": Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "raw": "'a'", + "start": 34, + "type": "Literal", + "value": "a", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "start": 28, + "type": "VariableDeclarator", + }, + ], + "end": 38, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 50, + "expression": Node { + "end": 49, + "left": Node { + "computed": true, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "object": Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "name": "x", + "start": 39, + "type": "Identifier", + }, + "property": Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "name": "key", + "start": 41, + "type": "Identifier", + }, + "start": 39, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "operator": "=", + "right": Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 9, + "line": 3, + }, + }, + "raw": "3", + "start": 48, + "type": "Literal", + "value": 3, + }, + "start": 39, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 39, + "type": "ExpressionStatement", + }, + ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +const key = 'a'; +x[key] = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + "key", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 20, + "id": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "name": "x", + "start": 4, + "type": "Identifier", + }, + "init": Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 8, + "line": 1, + }, + }, + "properties": Array [ + Node { + "computed": false, + "end": 13, + "key": Node { + "end": 10, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "a", + "start": 9, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 9, + "type": "Property", + "value": Node { + "end": 13, + "loc": SourceLocation { + "end": Position { + "column": 13, + "line": 1, + }, + "start": Position { + "column": 12, + "line": 1, + }, + }, + "raw": "1", + "start": 12, + "type": "Literal", + "value": 1, + }, + }, + Node { + "computed": false, + "end": 19, + "key": Node { + "end": 16, + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "name": "b", + "start": 15, + "type": "Identifier", + }, + "kind": "init", + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "method": false, + "shorthand": false, + "start": 15, + "type": "Property", + "value": Node { + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 18, + "line": 1, + }, + }, + "raw": "2", + "start": 18, + "type": "Literal", + "value": 2, + }, + }, + ], + "start": 8, + "type": "ObjectExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 4, + "line": 1, + }, + }, + "start": 4, + "type": "VariableDeclarator", + }, + ], + "end": 21, + "kind": "let", + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "declarations": Array [ + Node { + "end": 37, + "id": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "name": "key", + "start": 28, + "type": "Identifier", + }, + "init": Node { + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 12, + "line": 2, + }, + }, + "raw": "'a'", + "start": 34, + "type": "Literal", + "value": "a", + }, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 6, + "line": 2, + }, + }, + "start": 28, + "type": "VariableDeclarator", + }, + ], + "end": 38, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 16, + "line": 2, + }, + "start": Position { + "column": 0, + "line": 2, + }, + }, + "start": 22, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 50, + "expression": Node { + "end": 49, + "left": Node { + "computed": true, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 6, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "object": Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "name": "x", + "start": 39, + "type": "Identifier", + }, + "property": Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 3, + }, + "start": Position { + "column": 2, + "line": 3, + }, + }, + "name": "key", + "start": 41, + "type": "Identifier", + }, + "start": 39, + "type": "MemberExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "operator": "=", + "right": Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 3, + }, + "start": Position { + "column": 9, + "line": 3, + }, + }, + "raw": "3", + "start": 48, + "type": "Literal", + "value": 3, + }, + "start": 39, + "type": "AssignmentExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 39, + "type": "ExpressionStatement", + }, + ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "let x = {a: 1, b: 2}; +const key = 'a'; +x[key] = 3;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 3, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 34 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 62, + "expression": Node { + "arguments": Array [ + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nconst key = 'a';\\\\nx[key] = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +const key = 'a'; +x[key] = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nconst key = 'a';\\\\nx[key] = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 62, + "expression": Node { + "arguments": Array [ + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 1, b: 2};\\\\nconst key = 'a';\\\\nx[key] = 3;\\"", + "start": 6, + "type": "Literal", + "value": "let x = {a: 1, b: 2}; +const key = 'a'; +x[key] = 3;", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"let x = {a: 1, b: 2};\\\\nconst key = 'a';\\\\nx[key] = 3;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", + Array [ + Array [ + Array [ + "variable_declaration", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "object_expression", + Array [ + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "a", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 1, + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "key_value_pair", + Array [ + Array [ + "property", + Array [ + "b", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + 2, + null, + ], ], + null, ], + ], + ], + null, + ], + ], + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "constant_declaration", + Array [ + Array [ + "name", + Array [ + "key", + null, + ], + ], + Array [ + Array [ + "literal", + Array [ + "a", + null, + ], + ], + null, + ], + ], + ], + Array [ + Array [ + "object_assignment", + Array [ + Array [ + "object_access", + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + Array [ + Array [ + "name", + Array [ + "key", null, ], ], null, ], ], - null, ], + Array [ + Array [ + "literal", + Array [ + 3, + null, + ], + ], + null, + ], + ], + ], + null, + ], + ], + ], + null, + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 35 1`] = `"Line 1: Import default specifiers are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 35 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"import defaultExport from \\\\\\"one_module\\\\\\";\\"", + "start": 6, + "type": "Literal", + "value": "import defaultExport from \\"one_module\\";", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"import defaultExport from \\\\\\"one_module\\\\\\";\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"import defaultExport from \\\\\\"one_module\\\\\\";\\"", + "start": 6, + "type": "Literal", + "value": "import defaultExport from \\"one_module\\";", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "parse(\\"import defaultExport from \\\\\\"one_module\\\\\\";\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "import_declaration", + Array [ + Array [ + Array [ + "default", + null, + ], + null, + ], + Array [ + "one_module", + null, + ], + ], + ], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 35 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object { + "one_module": Object { + "state": null, + "tabs": Array [], + }, + }, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object { + "one_module": Object { + "bar": [Function], + "default": [Function], + "foo": [Function], + }, + }, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "defaultExport", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Object { + "loc": undefined, + "source": Object { + "loc": undefined, + "type": "Literal", + "value": "one_module", + }, + "specifiers": Array [ + Object { + "loc": undefined, + "local": Object { + "loc": undefined, + "name": "defaultExport", + "type": "Identifier", + }, + "type": "ImportDefaultSpecifier", + }, + ], + "type": "ImportDeclaration", + }, + ], + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "import defaultExport from \\"one_module\\";", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object { + "one_module": Object { + "state": null, + "tabs": Array [], + }, + }, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object { + "one_module": Object { + "bar": [Function], + "default": [Function], + "foo": [Function], + }, + }, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "defaultExport", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Object { + "loc": undefined, + "source": Object { + "loc": undefined, + "type": "Literal", + "value": "one_module", + }, + "specifiers": Array [ + Object { + "loc": undefined, + "local": Object { + "loc": undefined, + "name": "defaultExport", + "type": "Identifier", + }, + "type": "ImportDefaultSpecifier", + }, + ], + "type": "ImportDeclaration", + }, + ], + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "import defaultExport from \\"one_module\\";", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": undefined, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 36 1`] = `"Line 1: Export default declarations are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 36 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 40, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 33, + "type": "ReturnStatement", + }, + ], + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 29, + "line": 1, + }, + }, + "start": 29, + "type": "BlockStatement", + }, + "end": 44, + "expression": false, + "generator": false, + "id": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 24, + "line": 1, + }, + }, + "name": "f", + "start": 24, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 26, + "line": 1, + }, + }, + "name": "x", + "start": 26, + "type": "Identifier", + }, + ], + "start": 15, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 50, + "expression": Node { + "arguments": Array [ + Node { + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "raw": "5", + "start": 47, + "type": "Literal", + "value": 5, + }, + ], + "callee": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 45, + "type": "Identifier", + }, + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "ExpressionStatement", + }, + ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "export default function f(x) { + return x; +} +f(5);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "f", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 40, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 33, + "type": "ReturnStatement", + }, ], - null, + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 29, + "line": 1, + }, + }, + "start": 29, + "type": "BlockStatement", + }, + "end": 44, + "expression": false, + "generator": false, + "id": Node { + "end": 25, + "loc": SourceLocation { + "end": Position { + "column": 25, + "line": 1, + }, + "start": Position { + "column": 24, + "line": 1, + }, + }, + "name": "f", + "start": 24, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 15, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 27, + "loc": SourceLocation { + "end": Position { + "column": 27, + "line": 1, + }, + "start": Position { + "column": 26, + "line": 1, + }, + }, + "name": "x", + "start": 26, + "type": "Identifier", + }, ], - ], + "start": 15, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + Node { + "end": 50, + "expression": Node { + "arguments": Array [ + Node { + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 3, + "line": 4, + }, + "start": Position { + "column": 2, + "line": 4, + }, + }, + "raw": "5", + "start": 47, + "type": "Literal", + "value": 5, + }, + ], + "callee": Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "name": "f", + "start": 45, + "type": "Identifier", + }, + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 4, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 4, + }, + }, + "start": 45, + "type": "ExpressionStatement", + }, ], + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, ], - Array [ - Array [ - "application", - Array [ - Array [ - "name", - Array [ - "name", - null, - ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "export default function f(x) { + return x; +} +f(5);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 1: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "function name(a, b) { - const sum = a + b; - if (sum > 1) { - return sum; - } else { - if (a % 2 === 0) { - return -1; - } else if (b % 2 === 0) { - return 1; - } else { - return a > b ? 0 : -2; +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); } - } + return n === 0 + ? null + : es(s, n); } -name(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; -exports[`Syntaxes are allowed in the chapter they are introduced 2: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"(() => true)();\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "application", - Array [ - Array [ - "lambda_expression", - Array [ - null, - Array [ - Array [ - "return_statement", - Array [ - Array [ - "literal", - Array [ - true, - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], - Array [ - null, - null, +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 5, + }, } `; -exports[`Syntaxes are allowed in the chapter they are introduced 2: passes 1`] = ` +exports[`Syntaxes are allowed in the chapter they are introduced 36 3`] = ` Object { - "alertResult": Array [], - "code": "(() => true)();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 63, + "expression": Node { + "arguments": Array [ + Node { + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export default function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\"", + "start": 6, + "type": "Literal", + "value": "export default function f(x) { + return x; } -`; - -exports[`Syntaxes are allowed in the chapter they are introduced 3: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"((x, y) => { return x + y; })(1, 2);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "application", - Array [ - Array [ - "lambda_expression", - Array [ - Array [ - Array [ - "name", - Array [ - "x", - null, +f(5);", + }, ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - null, + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - null, - ], - ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - null, - ], - ], - ], - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - null, - ], - ], - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"export default function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 3: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "((x, y) => { return x + y; })(1, 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 4: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"true;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "literal", - Array [ - true, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 4: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "true;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 5: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"false;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "literal", - Array [ - false, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 5: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 6: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"'a string \\\\\\"\\\\\\" \\\\\\\\'\\\\\\\\'';\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "literal", - Array [ - "a string \\"\\" ''", - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 6: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "'a string \\"\\" \\\\'\\\\'';", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "a string \\"\\" ''", - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 7: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"31.4 + (-3.14e10) * -1 % 2 / 1.5;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "literal", - Array [ - 31.4, - null, - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "/", - Array [ - Array [ - "binary_operator_combination", - Array [ - "%", - Array [ - Array [ - "binary_operator_combination", - Array [ - "*", - Array [ - Array [ - "unary_operator_combination", - Array [ - "-unary", - Array [ - Array [ - "literal", - Array [ - 31400000000, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "unary_operator_combination", - Array [ - "-unary", - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - 1.5, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 7: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "31.4 + (-3.14e10) * -1 % 2 / 1.5;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 31.4, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 8: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "logical_composition", - Array [ - "||", - Array [ - Array [ - "logical_composition", - Array [ - "&&", - Array [ - Array [ - "logical_composition", - Array [ - "&&", - Array [ - Array [ - "logical_composition", - Array [ - "&&", - Array [ - Array [ - "logical_composition", - Array [ - "&&", - Array [ - Array [ - "binary_operator_combination", - Array [ - "===", - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "<", - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "<=", - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - ">=", - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - null, +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 63, + "expression": Node { + "arguments": Array [ + Node { + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"export default function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\"", + "start": 6, + "type": "Literal", + "value": "export default function f(x) { + return x; +} +f(5);", + }, + ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 62, + "loc": SourceLocation { + "end": Position { + "column": 62, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - Array [ - Array [ - "binary_operator_combination", - Array [ - ">", - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - false, - null, - ], - ], - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"export default function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 8: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "1 === 1 && 1 < 2 && 1 <= 2 && 2 >= 1 && 2 > 1 || false;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 9: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"true ? 1 : 2;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "conditional_expression", - Array [ - Array [ - "literal", - Array [ - true, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 9: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "true ? 1 : 2;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 10: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "null;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: null literals are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +function build_list(fun, n) { + return $build_list(n - 1, fun, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 10: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"null;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "literal", - Array [ - null, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 10: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "null;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 11: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "pair(1, null);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: null literals are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +function list_to_string(xs) { + return $list_to_string(xs, x => x); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 11: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"pair(1, null);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "application", - Array [ - Array [ - "name", - Array [ - "pair", - null, - ], - ], - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - null, - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 11: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "pair(1, null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - null, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +function reverse(xs) { + return $reverse(xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 12: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "list(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name list not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 12: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"list(1);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "application", - Array [ - Array [ - "name", - Array [ - "list", - null, - ], - ], - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +function append(xs, ys) { + return $append(xs, ys, xs => xs); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 12: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "list(1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - null, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 13: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "export function f(x) { - return x; +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); } -f(5);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Export named declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 13: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"export function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "export_named_declaration", - Array [ - Array [ - "function_declaration", - Array [ - Array [ - "name", - Array [ - "f", - null, - ], - ], - Array [ - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - Array [ - Array [ - "application", - Array [ - Array [ - "name", - Array [ - "f", - null, - ], - ], - Array [ - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 13: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "export function f(x) { - return x; +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); } -f(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 5, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 14: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "export const x = 1; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Export named declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 14: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"export const x = 1;\\\\nx;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "export_named_declaration", - Array [ - Array [ - "constant_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 14: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "export const x = 1; -x;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 15: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -while (i < 5) { - i = i + 1; +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -i;", - "displayResult": Array [], - "numErrors": 3, - "parsedErrors": "Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 3: Assignment expressions are not allowed -Line 2: While statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 15: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let i = 1;\\\\nwhile (i < 5) {\\\\n i = i + 1;\\\\n}\\\\ni;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "while_loop", - Array [ - Array [ - "binary_operator_combination", - Array [ - "<", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 15: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -while (i < 5) { - i = i + 1; +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); } -i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 5, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 16: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -for (i = 1; i < 5; i = i + 1) { +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); } -i;", - "displayResult": Array [], - "numErrors": 4, - "parsedErrors": "Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Assignment expressions are not allowed -Line 2: Assignment expressions are not allowed -Line 2: For statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 16: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let i = 1;\\\\nfor (i = 1; i < 5; i = i + 1) {\\\\n}\\\\ni;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], Array [ Array [ - "for_loop", + "export_default_declaration", Array [ Array [ - "assignment", + "function_declaration", Array [ Array [ "name", Array [ - "i", + "f", null, ], ], Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "<", Array [ Array [ "name", Array [ - "i", + "x", null, ], ], - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, - ], + null, ], - ], - ], - Array [ - Array [ - "assignment", Array [ Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ + "return_statement", Array [ - "binary_operator_combination", Array [ - "+", + "name", Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], + "x", + null, ], ], + null, ], - null, ], + null, ], ], + ], + ], + null, + ], + ], + Array [ + Array [ + "application", + Array [ + Array [ + "name", + Array [ + "f", + null, + ], + ], + Array [ Array [ Array [ - "sequence", + "literal", Array [ - null, + 5, null, ], ], null, ], + null, ], ], ], - ], - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], null, ], ], + null, ], - null, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 37 1`] = `"Line 2: Export default declarations are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 37 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 11, + "id": Node { + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "name": "x", + "start": 6, + "type": "Identifier", + }, + "init": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "1", + "start": 10, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "start": 6, + "type": "VariableDeclarator", + }, + ], + "end": 12, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 33, + "expression": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "name": "x", + "start": 31, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 31, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "const x = 1; +export default x; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 16: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -for (i = 1; i < 5; i = i + 1) { +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); } -i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 5, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 17: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -for (let j = 0; j < 5; j = j + 1) { - if (j < 1) { - continue; +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; } else { - i = i + 1; - if (j > 2) { - break; + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); } } } -i;", - "displayResult": Array [], - "numErrors": 8, - "parsedErrors": "Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Assignment expressions are not allowed -Line 4: Continue statements are not allowed -Line 6: Assignment expressions are not allowed -Line 8: Break statements are not allowed -Line 7: Missing \\"else\\" in \\"if-else\\" statement. -Line 2: For statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 17: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let i = 1;\\\\nfor (let j = 0; j < 5; j = j + 1) {\\\\n if (j < 1) {\\\\n continue;\\\\n } else {\\\\n i = i + 1;\\\\n if (j > 2) {\\\\n break;\\\\n }\\\\n }\\\\n}\\\\ni;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "for_loop", - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 0, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "<", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "conditional_statement", - Array [ - Array [ - "binary_operator_combination", - Array [ - "<", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "continue_statement", - null, - ], - Array [ - Array [ - "sequence", - Array [ - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "i", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "conditional_statement", - Array [ - Array [ - "binary_operator_combination", - Array [ - ">", - Array [ - Array [ - "name", - Array [ - "j", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - ], - Array [ - Array [ - "break_statement", - null, - ], - Array [ - Array [ - "sequence", - Array [ - null, - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "x", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "declarations": Array [ + Node { + "end": 11, + "id": Node { + "end": 7, + "loc": SourceLocation { + "end": Position { + "column": 7, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "name": "x", + "start": 6, + "type": "Identifier", + }, + "init": Node { + "end": 11, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "raw": "1", + "start": 10, + "type": "Literal", + "value": 1, + }, + "loc": SourceLocation { + "end": Position { + "column": 11, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "start": 6, + "type": "VariableDeclarator", + }, + ], + "end": 12, + "kind": "const", + "loc": SourceLocation { + "end": Position { + "column": 12, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "typability": "NotYetTyped", + "type": "VariableDeclaration", + }, + Node { + "end": 33, + "expression": Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "name": "x", + "start": 31, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 3, + }, + }, + "start": 31, + "type": "ExpressionStatement", + }, + ], + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 2, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - Array [ - Array [ - "name", - Array [ - "i", - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, ], - ], - null, - ], - ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "const x = 1; +export default x; +x;", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 17: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 1; -for (let j = 0; j < 5; j = j + 1) { - if (j < 1) { - continue; + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; } else { - i = i + 1; - if (j > 2) { - break; + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); } } } -i;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 4, - "resultStatus": "finished", - "visualiseListResult": Array [], + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 18: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "[];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Array expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 18: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"[];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "array_expression", - Array [ - null, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 18: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "[];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [], - "resultStatus": "finished", - "visualiseListResult": Array [], +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 19: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "[1, 2, 3];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Array expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 19: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"[1, 2, 3];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "array_expression", - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 19: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "[1, 2, 3];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - 2, - 3, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 20: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "[1, 2, 3][1];", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Array expressions are not allowed -Line 1: Member expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 20: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"[1, 2, 3][1];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_access", - Array [ - Array [ - "array_expression", - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 20: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "[1, 2, 3][1];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 21: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = [1, 2, 3]; -x[1];", - "displayResult": Array [], - "numErrors": 3, - "parsedErrors": "Line 1: Array expressions are not allowed -Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Member expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 21: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = [1, 2, 3];\\\\nx[1];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "array_expression", - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "object_access", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 21: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = [1, 2, 3]; -x[1];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 22: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = [1, 2, 3]; -x[1] = 4;", - "displayResult": Array [], - "numErrors": 4, - "parsedErrors": "Line 1: Array expressions are not allowed -Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Member expressions are not allowed -Line 2: Assignment expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 22: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = [1, 2, 3];\\\\nx[1] = 4;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "array_expression", - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "object_assignment", - Array [ - Array [ - "object_access", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "literal", - Array [ - 4, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 22: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = [1, 2, 3]; -x[1] = 4;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 4, - "resultStatus": "finished", - "visualiseListResult": Array [], +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 23: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3; -let y = 4; -let z = 5; -x = y = z = 6; -x;", - "displayResult": Array [], - "numErrors": 6, - "parsedErrors": "Line 1: Mutable variable declaration using keyword 'let' is not allowed. -Line 2: Mutable variable declaration using keyword 'let' is not allowed. -Line 3: Mutable variable declaration using keyword 'let' is not allowed. -Line 4: Assignment expressions are not allowed -Line 4: Assignment expressions are not allowed -Line 4: Assignment expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 23: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = 3;\\\\nlet y = 4;\\\\nlet z = 5;\\\\nx = y = z = 6;\\\\nx;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": 1, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 37 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 45, + "expression": Node { + "arguments": Array [ + Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"const x = 1;\\\\nexport default x;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "const x = 1; +export default x; +x;", + }, ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - ], - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 4, - null, + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - null, - ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "z", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - Array [ - Array [ - "assignment", - Array [ - Array [ - "name", - Array [ - "z", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 6, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - ], - null, - ], - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - ], - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"const x = 1;\\\\nexport default x;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 23: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3; -let y = 4; -let z = 5; -x = y = z = 6; -x;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 6, - "resultStatus": "finished", - "visualiseListResult": Array [], +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 24: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y, ...z) { - return x + y; +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); } -f(...[1, 2]);", - "displayResult": Array [], - "numErrors": 3, - "parsedErrors": "Line 1: Rest elements are not allowed -Line 4: Array expressions are not allowed -Line 4: Spread elements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 24: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"function f(x, y, ...z) {\\\\n return x + y;\\\\n}\\\\nf(...[1, 2]);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "function_declaration", - Array [ - Array [ - "name", - Array [ - "f", - null, - ], - ], - Array [ - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - Array [ - Array [ - "rest_element", - Array [ - Array [ - "name", - Array [ - "z", - null, - ], - ], - null, - ], - ], - null, - ], +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 45, + "expression": Node { + "arguments": Array [ + Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"const x = 1;\\\\nexport default x;\\\\nx;\\"", + "start": 6, + "type": "Literal", + "value": "const x = 1; +export default x; +x;", + }, ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "binary_operator_combination", - Array [ - "+", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "y", - null, - ], - ], - null, - ], - ], - ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - ], - Array [ - Array [ - "application", - Array [ - Array [ - "name", - Array [ - "f", - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - Array [ - Array [ - Array [ - "spread_element", - Array [ - Array [ - "array_expression", - Array [ - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - null, - ], - ], - null, - ], - ], - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"const x = 1;\\\\nexport default x;\\\\nx;\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 24: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y, ...z) { - return x + y; +function append(xs, ys) { + return $append(xs, ys, xs => xs); } -f(...[1, 2]);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 25: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({});", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 25: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({});\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_expression", - Array [ - null, - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +function remove(v, xs) { + return $remove(v, xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 25: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "({});", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Object {}, - "resultStatus": "finished", - "visualiseListResult": Array [], +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 26: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2});", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +function remove_all(v, xs) { + return $remove_all(v, xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 26: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({a: 1, b: 2});\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 26: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2});", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Object { - "a": 1, - "b": 2, - }, - "resultStatus": "finished", - "visualiseListResult": Array [], +function filter(pred, xs) { + return $filter(pred, xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 27: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2})['a'];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 27: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({a: 1, b: 2})['a'];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_access", - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - "a", - null, - ], - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +function enum_list(start, end) { + return $enum_list(start, end, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 27: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2})['a'];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 28: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2}).a;", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Object expressions are not allowed -Line 1: Dot abbreviations are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 28: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({a: 1, b: 2}).a;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_access", - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 28: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "({a: 1, b: 2}).a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 29: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({'a': 1, 'b': 2}).a;", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Object expressions are not allowed -Line 1: Dot abbreviations are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 29: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({'a': 1, 'b': 2}).a;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_access", - Array [ +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", Array [ - "object_expression", Array [ Array [ + "constant_declaration", Array [ - "key_value_pair", + Array [ + "name", + Array [ + "x", + null, + ], + ], Array [ Array [ "literal", Array [ - "a", + 1, null, ], ], + null, + ], + ], + ], + Array [ + Array [ + "export_default_declaration", + Array [ Array [ + "name", Array [ - "literal", - Array [ - 1, - null, - ], + "x", + null, ], - null, ], + null, ], ], Array [ Array [ - "key_value_pair", + "name", Array [ - Array [ - "literal", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], + "x", + null, ], ], null, ], ], - null, - ], - ], - Array [ - Array [ - "property", - Array [ - "a", - null, - ], ], null, ], ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + }, } `; -exports[`Syntaxes are allowed in the chapter they are introduced 29: passes 1`] = ` +exports[`Syntaxes are allowed in the chapter they are introduced 38 1`] = `"Line 4: Export default declarations are not allowed"`; + +exports[`Syntaxes are allowed in the chapter they are introduced 38 2`] = ` Object { - "alertResult": Array [], - "code": "({'a': 1, 'b': 2}).a;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "square", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 35, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 30, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "operator": "*", + "right": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "name": "x", + "start": 34, + "type": "Identifier", + }, + "start": 30, + "type": "BinaryExpression", + }, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 23, + "type": "ReturnStatement", + }, + ], + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 19, + "line": 1, + }, + }, + "start": 19, + "type": "BlockStatement", + }, + "end": 38, + "expression": false, + "generator": false, + "id": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "square", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "name": "x", + "start": 16, + "type": "Identifier", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + ], + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "function square(x) { + return x * x; } -`; +export { square as default };", + " -exports[`Syntaxes are allowed in the chapter they are introduced 30: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "({1: 1, 2: 2})['1'];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 30: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"({1: 1, 2: 2})['1'];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "object_access", - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - "1", - null, - ], - ], - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 30: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "({1: 1, 2: 2})['1'];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 31: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "const key = 'a'; -({a: 1, b: 2})[key];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 31: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"const key = 'a';\\\\n({a: 1, b: 2})[key];\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "constant_declaration", - Array [ - Array [ - "name", - Array [ - "key", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - "a", - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "object_access", - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "key", - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 31: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "const key = 'a'; -({a: 1, b: 2})[key];", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 32: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -x.a = 3;", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Object expressions are not allowed -Line 2: Dot abbreviations are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 32: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = {a: 1, b: 2};\\\\nx.a = 3;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "object_assignment", - Array [ - Array [ - "object_access", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "property", - Array [ - "a", - null, - ], +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + "square", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "body": Node { + "body": Array [ + Node { + "argument": Node { + "end": 35, + "left": Node { + "end": 31, + "loc": SourceLocation { + "end": Position { + "column": 10, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "name": "x", + "start": 30, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 9, + "line": 2, + }, + }, + "operator": "*", + "right": Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 14, + "line": 2, + }, + "start": Position { + "column": 13, + "line": 2, + }, + }, + "name": "x", + "start": 34, + "type": "Identifier", + }, + "start": 30, + "type": "BinaryExpression", + }, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 2, + }, + "start": Position { + "column": 2, + "line": 2, + }, + }, + "start": 23, + "type": "ReturnStatement", + }, + ], + "end": 38, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 19, + "line": 1, + }, + }, + "start": 19, + "type": "BlockStatement", + }, + "end": 38, + "expression": false, + "generator": false, + "id": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 9, + "line": 1, + }, + }, + "name": "square", + "start": 9, + "type": "Identifier", + }, + "loc": SourceLocation { + "end": Position { + "column": 1, + "line": 3, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "params": Array [ + Node { + "end": 17, + "loc": SourceLocation { + "end": Position { + "column": 17, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "name": "x", + "start": 16, + "type": "Identifier", + }, + ], + "start": 0, + "typability": "NotYetTyped", + "type": "FunctionDeclaration", + }, + ], + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 4, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - null, + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - ], - null, - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "function square(x) { + return x * x; } -`; +export { square as default };", + " -exports[`Syntaxes are allowed in the chapter they are introduced 32: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -x.a = 3;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 33: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -x['a'] = 3;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 33: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = {a: 1, b: 2};\\\\nx['a'] = 3;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": undefined, + }, +} +`; + +exports[`Syntaxes are allowed in the chapter they are introduced 38 3`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 81, + "expression": Node { + "arguments": Array [ + Node { + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 79, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function square(x) {\\\\n return x * x;\\\\n}\\\\nexport { square as default };\\"", + "start": 6, + "type": "Literal", + "value": "function square(x) { + return x * x; +} +export { square as default };", + }, ], - null, - ], - ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 80, + "loc": SourceLocation { + "end": Position { + "column": 80, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, ], - Array [ - Array [ - "object_assignment", - Array [ - Array [ - "object_access", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - "a", - null, - ], - ], - null, + "end": 81, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - null, - ], - ], - null, + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"function square(x) {\\\\n return x * x;\\\\n}\\\\nexport { square as default };\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 33: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -x['a'] = 3;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 34: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -const key = 'a'; -x[key] = 3;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Object expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 34: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"let x = {a: 1, b: 2};\\\\nconst key = 'a';\\\\nx[key] = 3;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "variable_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "object_expression", - Array [ - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "a", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "key_value_pair", - Array [ - Array [ - "property", - Array [ - "b", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 2, - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - null, +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 81, + "expression": Node { + "arguments": Array [ + Node { + "end": 79, + "loc": SourceLocation { + "end": Position { + "column": 79, + "line": 1, + }, + "start": Position { + "column": 6, + "line": 1, + }, + }, + "raw": "\\"function square(x) {\\\\n return x * x;\\\\n}\\\\nexport { square as default };\\"", + "start": 6, + "type": "Literal", + "value": "function square(x) { + return x * x; +} +export { square as default };", + }, ], - ], - null, - ], + "callee": Node { + "end": 5, + "loc": SourceLocation { + "end": Position { + "column": 5, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "parse", + "start": 0, + "type": "Identifier", + }, + "end": 80, + "loc": SourceLocation { + "end": Position { + "column": 80, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, ], + "end": 81, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, ], - Array [ - Array [ - "constant_declaration", - Array [ - Array [ - "name", - Array [ - "key", - null, - ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "literal", - Array [ - "a", - null, - ], - ], - null, + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - ], - ], - Array [ - Array [ - "object_assignment", - Array [ - Array [ - "object_access", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "key", - null, - ], - ], - null, + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, ], - Array [ - Array [ - "literal", - Array [ - 3, - null, - ], - ], - null, + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, ], - ], - null, - ], - ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], + "unTypecheckedCode": Array [ + "parse(\\"function square(x) {\\\\n return x * x;\\\\n}\\\\nexport { square as default };\\");", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 34: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = {a: 1, b: 2}; -const key = 'a'; -x[key] = 3;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 35: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "import defaultExport from \\"one_module\\";", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Import default specifiers are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 35: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"import defaultExport from \\\\\\"one_module\\\\\\";\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "import_declaration", - Array [ - Array [ - Array [ - "default", - null, - ], - null, - ], - Array [ - "one_module", - null, - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 35: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "import defaultExport from \\"one_module\\";", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 36: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "export default function f(x) { - return x; +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); } -f(5);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Export default declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 36: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"export default function f(x) {\\\\n return x;\\\\n}\\\\nf(5);\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "export_default_declaration", - Array [ - Array [ - "function_declaration", - Array [ - Array [ - "name", - Array [ - "f", - null, - ], - ], - Array [ - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - Array [ - Array [ - "return_statement", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - ], - null, - ], - ], - ], - ], - null, - ], - ], - Array [ - Array [ - "application", - Array [ - Array [ - "name", - Array [ - "f", - null, - ], - ], - Array [ - Array [ - Array [ - "literal", - Array [ - 5, - null, - ], - ], - null, - ], - null, - ], - ], - ], - null, - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 36: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "export default function f(x) { - return x; +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); } -f(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 5, - "resultStatus": "finished", - "visualiseListResult": Array [], + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 37: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = 1; -export default x; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Export default declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 37: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"const x = 1;\\\\nexport default x;\\\\nx;\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ - Array [ - Array [ - "constant_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - Array [ - Array [ - "literal", - Array [ - 1, - null, - ], - ], - null, - ], - ], - ], - Array [ - Array [ - "export_default_declaration", - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - ], - Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], - null, - ], - ], - ], - null, - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 37: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = 1; -export default x; -x;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 38: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "function square(x) { - return x * x; +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); } -export { square as default };", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Export default declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); } -`; -exports[`Syntaxes are allowed in the chapter they are introduced 38: parse passes 1`] = ` -Object { - "alertResult": Array [], - "code": "parse(\\"function square(x) {\\\\n return x * x;\\\\n}\\\\nexport { square as default };\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "sequence", - Array [ +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": Array [ + "sequence", Array [ Array [ - "function_declaration", Array [ + "function_declaration", Array [ - "name", Array [ - "square", - null, + "name", + Array [ + "square", + null, + ], ], - ], - Array [ Array [ Array [ - "name", Array [ - "x", - null, + "name", + Array [ + "x", + null, + ], ], + null, ], - null, - ], - Array [ Array [ - "return_statement", Array [ + "return_statement", Array [ - "binary_operator_combination", Array [ - "*", + "binary_operator_combination", Array [ - Array [ - "name", - Array [ - "x", - null, - ], - ], + "*", Array [ Array [ "name", @@ -4636,84 +419402,53 @@ Object { null, ], ], - null, + Array [ + Array [ + "name", + Array [ + "x", + null, + ], + ], + null, + ], ], ], ], + null, ], - null, ], + null, ], - null, ], ], ], - ], - Array [ Array [ - "export_named_declaration", Array [ + "export_named_declaration", Array [ Array [ - "name", Array [ - "default", - null, + "name", + Array [ + "default", + null, + ], ], ], + null, ], - null, ], + null, ], - null, ], + null, ], - null, ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`Syntaxes are allowed in the chapter they are introduced 38: passes 1`] = ` -Object { - "alertResult": Array [], - "code": "function square(x) { - return x * x; -} -export { square as default };", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], + }, } `; -exports[`Syntaxes are allowed in the chapter they are introduced 39: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "import { default as x } from './a.js';", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Import default specifiers are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Syntaxes are allowed in the chapter they are introduced 39 1`] = `"Line 1: Import default specifiers are not allowed"`; -exports[`Syntaxes are allowed in the chapter they are introduced 40: fails a chapter below 1`] = ` -Object { - "alertResult": Array [], - "code": "import * as a from 'one_module';", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Namespace imports are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; +exports[`Syntaxes are allowed in the chapter they are introduced 40 1`] = `"Line 1: Namespace imports are not allowed"`; diff --git a/src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap b/src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap deleted file mode 100644 index 2052f8406..000000000 --- a/src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap +++ /dev/null @@ -1,1471 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Cannot have if without else in chapter <= 2 - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -if (true) { 5; }", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing \\"else\\" in \\"if-else\\" statement. -This \\"if\\" block requires corresponding \\"else\\" block which will be -evaluated when true expression evaluates to false. - -Later in the course we will lift this restriction and allow \\"if\\" without -else. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot have if without else in chapter <= 2: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) { 5; }", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing \\"else\\" in \\"if-else\\" statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot have incomplete statements - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -5", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 1: Missing semicolon at the end of statement -Every statement must be terminated by a semicolon. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot have incomplete statements: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "5", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing semicolon at the end of statement", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank expressions in for loop - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (;;) { -break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing init, test, update expressions in for statement. -This for statement requires all three parts (initialiser, test, update) to be present. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank expressions in for loop: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (;;) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing init, test, update expressions in for statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank init in for loop - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (; i < 3; i = i + 1) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing init expression in for statement. -This for statement requires all three parts (initialiser, test, update) to be present. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank init in for loop: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (; i < 3; i = i + 1) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing init expression in for statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank test in for loop - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (let i = 0; ; i = i + 1) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing test expression in for statement. -This for statement requires all three parts (initialiser, test, update) to be present. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank test in for loop: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; ; i = i + 1) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing test expression in for statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank update in for loop - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (let i = 0; i < 3;) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing update expression in for statement. -This for statement requires all three parts (initialiser, test, update) to be present. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave blank update in for loop: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 3;) { - break; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing update expression in for statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave while loop predicate blank - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -while () { - x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 7: SyntaxError: Unexpected token (2:7) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot leave while loop predicate blank: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "while () { - x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: Unexpected token (1:7)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use destructuring declarations - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = [1, 2]; -let [a, b] = x; -a;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 4: Array patterns are not allowed -You are trying to use Array patterns, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use destructuring declarations: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = [1, 2]; -let [a, b] = x; -a;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Array patterns are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use function expressions - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -(function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); })(4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 1: Function expressions are not allowed -You are trying to use Function expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use function expressions - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -(function(x) { return x + 1; })(4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 1: Function expressions are not allowed -You are trying to use Function expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use function expressions: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "(function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); })(4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Function expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use function expressions: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "(function(x) { return x + 1; })(4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Function expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use multiple declarations - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = 3, y = 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Multiple declaration in a single statement. -Split the variable declaration into multiple lines as follows - - let x = 3; - let y = 5; - -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use multiple declarations: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3, y = 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Multiple declaration in a single statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update expressions - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = 3; -x++; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 0: Update expressions are not allowed -You are trying to use Update expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update expressions: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3; -x++; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Update expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update statements - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = 3; -x += 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 0: The assignment operator += is not allowed. Use = instead. - - x = x + 5; -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update statements - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = 3; -x <<= 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 0: The assignment operator <<= is not allowed. Use = instead. - -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update statements: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3; -x += 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: The assignment operator += is not allowed. Use = instead.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Cannot use update statements: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "let x = 3; -x <<= 5; -x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: The assignment operator <<= is not allowed. Use = instead.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No array expressions in chapter 2 - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -[];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Array expressions are not allowed -You are trying to use Array expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No array expressions in chapter 2: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Array expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No empty statements - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Empty statements are not allowed -You are trying to use Empty statements, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No empty statements: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": ";", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Empty statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No spread in array expressions: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[...[]];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Spread syntax is not allowed in arrays.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No trailing commas in arrays - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -[1,];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 2: Trailing comma -Please remove the trailing comma -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No trailing commas in arrays: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[1,];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Trailing comma", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`No trailing commas in objects: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "({ - a: 1, - b: 2, -});", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Trailing comma", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`for needs braces - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (let i = 0; i < 1; i = i + 1) - i;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Missing curly braces around \\"for\\" block. -Remember to enclose your \\"for\\" block with braces: - - for (let i = 0; i < 1; i = i + 1) { - //code goes here - } -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`for needs braces: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 1; i = i + 1) - i;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing curly braces around \\"for\\" block.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`if needs braces - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -if (true) - true; -else - false;", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 2, Column 0: Missing curly braces around \\"if\\" block. -if block need to be enclosed with a pair of curly braces. - -if (true) { - true; -} - -An exception is when you have an \\"if\\" followed by \\"else if\\", in this case -\\"else if\\" block does not need to be surrounded by curly braces. - -if (someCondition) { - // ... -} else /* notice missing { here */ if (someCondition) { - // ... -} else { - // ... -} - -Rationale: Readability in dense packed code. - -In the snippet below, for instance, with poor indentation it is easy to -mistaken hello() and world() to belong to the same branch of logic. - -if (someCondition) { - 2; -} else - hello(); -world(); - -Line 2, Column 0: Missing curly braces around \\"else\\" block. -else block need to be enclosed with a pair of curly braces. - -else { - false; -} - -An exception is when you have an \\"if\\" followed by \\"else if\\", in this case -\\"else if\\" block does not need to be surrounded by curly braces. - -if (someCondition) { - // ... -} else /* notice missing { here */ if (someCondition) { - // ... -} else { - // ... -} - -Rationale: Readability in dense packed code. - -In the snippet below, for instance, with poor indentation it is easy to -mistaken hello() and world() to belong to the same branch of logic. - -if (someCondition) { - 2; -} else - hello(); -world(); -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`if needs braces: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) - true; -else - false;", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Missing curly braces around \\"if\\" block. -Line 1: Missing curly braces around \\"else\\" block.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no anonymous function declarations - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -export default function (x) { - return x * x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 15: The 'function' keyword needs to be followed by a name. -Function declarations without a name are similar to function expressions, which are banned. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no anonymous function declarations: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "export default function (x) { - return x * x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: The 'function' keyword needs to be followed by a name.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no assigning to reserved keywords - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -package = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: SyntaxError: The keyword 'package' is reserved (2:0) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no assigning to reserved keywords - verbose: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -[1, , 3];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: No holes are allowed in array literals. -No holes (empty slots with no content inside) are allowed in array literals. -You probably have an extra comma, which creates a hole. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no assigning to reserved keywords: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "package = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: The keyword 'package' is reserved (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no classes - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -class Box { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 2, Column 10: Class bodys are not allowed -You are trying to use Class bodys, which is not allowed (yet). - -Line 2, Column 0: Class declarations are not allowed -You are trying to use Class declarations, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no classes: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "class Box { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Class bodys are not allowed -Line 1: Class declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no declaration without assignment - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 4: Missing value in variable declaration. -A variable declaration assigns a value to a name. -For instance, to assign 20 to x, you can write: - - let x = 20; - - x + x; // 40 -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no declaration without assignment: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Missing value in variable declaration.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no declaring reserved keywords - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let yield = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 4: SyntaxError: The keyword 'yield' is reserved (2:4) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no declaring reserved keywords: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let yield = 5;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: The keyword 'yield' is reserved (1:4)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no for in loops - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (let i in { a: 1, b: 2 }) { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 2, Column 9: Missing value in variable declaration. -A variable declaration assigns a value to a name. -For instance, to assign 20 to i, you can write: - - let i = 20; - - i + i; // 40 - -Line 2, Column 0: For in statements are not allowed -You are trying to use For in statements, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no for in loops: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i in { a: 1, b: 2 }) { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Missing value in variable declaration. -Line 1: For in statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no for of loops - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -for (let i of list()) { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 2, Column 9: Missing value in variable declaration. -A variable declaration assigns a value to a name. -For instance, to assign 20 to i, you can write: - - let i = 20; - - i + i; // 40 - -Line 2, Column 0: For of statements are not allowed -You are trying to use For of statements, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no for of loops: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i of list()) { -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Missing value in variable declaration. -Line 1: For of statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no generator functions - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function* gen() { - yield 2; - return 1; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Yield expressions are not allowed -You are trying to use Yield expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no generator functions: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function* gen() { - yield 2; - return 1; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Yield expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no holes in arrays: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "[1, , 3];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: No holes are allowed in array literals.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no implicit undefined return - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f() { - return; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Missing value in return statement. -This return statement is missing a value. -For instance, to return the value 42, you can write - - return 42; -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no implicit undefined return: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - return; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Missing value in return statement.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no interface - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -interface Box { -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: SyntaxError: The keyword 'interface' is reserved (2:0) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no interface: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "interface Box { -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: The keyword 'interface' is reserved (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no namespace imports - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -import * as x from \\"one_module\\";", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 7: Namespace imports are not allowed -You are trying to use Namespace imports, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no namespace imports: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "import * as x from \\"one_module\\";", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Namespace imports are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no regexp - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -/pattern/", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 2, Column 9: Missing semicolon at the end of statement -Every statement must be terminated by a semicolon. - -Line 2, Column 0: 'RegExp' literals are not allowed. - -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no regexp: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "/pattern/", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 1: Missing semicolon at the end of statement -Line 1: 'RegExp' literals are not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no repeated params - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f(x, x) { - return x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 14: SyntaxError: Argument name clash (2:14) -There is a syntax error in your program -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no repeated params: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, x) { - return x; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: Argument name clash (1:14)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no sequence expression - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 1: Sequence expressions are not allowed -You are trying to use Sequence expressions, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no sequence expression: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "(1, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Sequence expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no super - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -class BoxError extends Error { - constructor() { - super(1); - } -}", - "displayResult": Array [], - "numErrors": 5, - "parsedErrors": "Line 4, Column 4: Supers are not allowed -You are trying to use Supers, which is not allowed (yet). - -Line 3, Column 13: Function expressions are not allowed -You are trying to use Function expressions, which is not allowed (yet). - -Line 3, Column 2: Method definitions are not allowed -You are trying to use Method definitions, which is not allowed (yet). - -Line 2, Column 29: Class bodys are not allowed -You are trying to use Class bodys, which is not allowed (yet). - -Line 2, Column 0: Class declarations are not allowed -You are trying to use Class declarations, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no super: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "class BoxError extends Error { - constructor() { - super(1); - } -}", - "displayResult": Array [], - "numErrors": 5, - "parsedErrors": "Line 3: Supers are not allowed -Line 2: Function expressions are not allowed -Line 2: Method definitions are not allowed -Line 1: Class bodys are not allowed -Line 1: Class declarations are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no template literals - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -'hi'", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 4: Missing semicolon at the end of statement -Every statement must be terminated by a semicolon. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no this, no new - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function Box() { - this[0] = 5; -} -const box = new Box();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 2: Expected string as prop, got number. -Expected string as prop, got number. -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no this, no new: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function Box() { - this[0] = 5; -} -const box = new Box();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Expected string as prop, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no try statements - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -function f(x, y) { - return x + y; -} -try { - f([1, 2]); -} catch (e) { - display(e); -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 7, Column 2: Catch clauses are not allowed -You are trying to use Catch clauses, which is not allowed (yet). - -Line 5, Column 0: Try statements are not allowed -You are trying to use Try statements, which is not allowed (yet). -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no try statements: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f(x, y) { - return x + y; -} -try { - f([1, 2]); -} catch (e) { - display(e); -}", - "displayResult": Array [], - "numErrors": 2, - "parsedErrors": "Line 6: Catch clauses are not allowed -Line 4: Try statements are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no unspecified operators - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -1 << 10;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Operator '<<' is not allowed. - -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no unspecified operators: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1 << 10;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Operator '<<' is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no unspecified unary operators - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let x = 5; -typeof x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 0: Operator 'typeof' is not allowed. - -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no unspecified unary operators: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 5; -typeof x;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Operator 'typeof' is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no var statements - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -var x = 1;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2, Column 0: Variable declaration using \\"var\\" is not allowed. -Use keyword \\"let\\" instead, to declare a variable: - - let x = 1; -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`no var statements: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "var x = 1;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Variable declaration using \\"var\\" is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`while needs braces - verbose: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"enable verbose\\"; -let i = 0; -while (i < 1) - i = i + 1;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3, Column 0: Missing curly braces around \\"while\\" block. -Remember to enclose your \\"while\\" block with braces: - - while (i < 1) { - //code goes here - } -", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`while needs braces: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let i = 0; -while (i < 1) - i = i + 1;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Missing curly braces around \\"while\\" block.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/parser/__tests__/__snapshots__/tokenize.ts.snap b/src/parser/__tests__/__snapshots__/tokenize.ts.snap deleted file mode 100644 index ed8697f07..000000000 --- a/src/parser/__tests__/__snapshots__/tokenize.ts.snap +++ /dev/null @@ -1,262 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`tokenize prints suitable error when tokenization fails: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(tokenize(\\"\\\\\\"\\"));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: SyntaxError: Unterminated string constant (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`tokenize works even with parse errors: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(tokenize(\\"function f(x) {\\\\n;;;;;;;\\"));", - "displayResult": Array [ - "list(\\"function\\", \\"f\\", \\"(\\", \\"x\\", \\")\\", \\"{\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\")", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "function", - Array [ - "f", - Array [ - "(", - Array [ - "x", - Array [ - ")", - Array [ - "{", - Array [ - ";", - Array [ - ";", - Array [ - ";", - Array [ - ";", - Array [ - ";", - Array [ - ";", - Array [ - ";", - null, - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`tokenize works for a good program: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(tokenize(\\"function f(x) {\\\\n const y = x + x + x + \\\\\\"123\\\\\\";\\\\n return z => (a, b) => {\\\\n let w = z + 1;\\\\n return y;\\\\n };\\\\n}\\\\nf(\\\\\\"55\\\\\\");\\"));", - "displayResult": Array [ - "list(\\"function\\", - \\"f\\", - \\"(\\", - \\"x\\", - \\")\\", - \\"{\\", - \\"const\\", - \\"y\\", - \\"=\\", - \\"x\\", - \\"+\\", - \\"x\\", - \\"+\\", - \\"x\\", - \\"+\\", - \\"\\\\\\"123\\\\\\"\\", - \\";\\", - \\"return\\", - \\"z\\", - \\"=>\\", - \\"(\\", - \\"a\\", - \\",\\", - \\"b\\", - \\")\\", - \\"=>\\", - \\"{\\", - \\"let\\", - \\"w\\", - \\"=\\", - \\"z\\", - \\"+\\", - \\"1\\", - \\";\\", - \\"return\\", - \\"y\\", - \\";\\", - \\"}\\", - \\";\\", - \\"}\\", - \\"f\\", - \\"(\\", - \\"\\\\\\"55\\\\\\"\\", - \\")\\", - \\";\\")", - ], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - "function", - Array [ - "f", - Array [ - "(", - Array [ - "x", - Array [ - ")", - Array [ - "{", - Array [ - "const", - Array [ - "y", - Array [ - "=", - Array [ - "x", - Array [ - "+", - Array [ - "x", - Array [ - "+", - Array [ - "x", - Array [ - "+", - Array [ - "\\"123\\"", - Array [ - ";", - Array [ - "return", - Array [ - "z", - Array [ - "=>", - Array [ - "(", - Array [ - "a", - Array [ - ",", - Array [ - "b", - Array [ - ")", - Array [ - "=>", - Array [ - "{", - Array [ - "let", - Array [ - "w", - Array [ - "=", - Array [ - "z", - Array [ - "+", - Array [ - "1", - Array [ - ";", - Array [ - "return", - Array [ - "y", - Array [ - ";", - Array [ - "}", - Array [ - ";", - Array [ - "}", - Array [ - "f", - Array [ - "(", - Array [ - "\\"55\\"", - Array [ - ")", - Array [ - ";", - null, - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/parser/__tests__/allowed-syntax.ts b/src/parser/__tests__/allowed-syntax.ts index 07d913834..1122dd81f 100644 --- a/src/parser/__tests__/allowed-syntax.ts +++ b/src/parser/__tests__/allowed-syntax.ts @@ -343,21 +343,13 @@ test.each([ (chapter: Chapter, snippet: string, skipSuccessTests: boolean = false) => { snippet = stripIndent(snippet) const parseSnippet = `parse(${JSON.stringify(snippet)});` - const tests: ReturnType[] = [] + const tests: Promise[] = [] if (!skipSuccessTests) { - tests.push( - snapshotSuccess(snippet, { chapter, native: chapter !== Chapter.LIBRARY_PARSER }, 'passes') - ) - tests.push( - snapshotSuccess( - parseSnippet, - { chapter: Math.max(4, chapter), native: true }, - 'parse passes' - ) - ) + tests.push(snapshotSuccess(snippet, chapter)) + tests.push(snapshotSuccess(parseSnippet, Math.max(4, chapter))) } if (chapter > 1) { - tests.push(snapshotFailure(snippet, { chapter: chapter - 1 }, 'fails a chapter below')) + tests.push(snapshotFailure(snippet, chapter - 1)) } return Promise.all(tests) } diff --git a/src/parser/__tests__/disallowed-syntax.ts b/src/parser/__tests__/disallowed-syntax.ts index 5f6487027..3d500eed3 100644 --- a/src/parser/__tests__/disallowed-syntax.ts +++ b/src/parser/__tests__/disallowed-syntax.ts @@ -1014,7 +1014,7 @@ test('no this, no new', () => { const box = new Box(); `, { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(`"Line 2: Expected string as prop, got number."`) + ).toMatchInlineSnapshot(`"Line 4: TypeError: Box is not a constructor"`) }) test('no this, no new - verbose', () => { @@ -1027,11 +1027,7 @@ test('no this, no new - verbose', () => { const box = new Box(); `, { chapter: Chapter.LIBRARY_PARSER } - ).toMatchInlineSnapshot(` - "Line 3, Column 2: Expected string as prop, got number. - Expected string as prop, got number. - " - `) + ).toMatchInlineSnapshot(`""`) }) test('no unspecified operators', () => { diff --git a/src/parser/__tests__/fullTS.ts b/src/parser/__tests__/fullTS.ts index 776a06cd7..f2f6922c1 100644 --- a/src/parser/__tests__/fullTS.ts +++ b/src/parser/__tests__/fullTS.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter } from '../../types' import { FullTSParser } from '../fullTS' diff --git a/src/parser/__tests__/python.ts b/src/parser/__tests__/python.ts index 4b2ee5aa7..d0c09195b 100644 --- a/src/parser/__tests__/python.ts +++ b/src/parser/__tests__/python.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter } from '../../types' import { FatalSyntaxError } from '../errors' import { parse } from '../parser' diff --git a/src/parser/__tests__/tokenize.ts b/src/parser/__tests__/tokenize.ts index d67eadc77..80cedcd1f 100644 --- a/src/parser/__tests__/tokenize.ts +++ b/src/parser/__tests__/tokenize.ts @@ -17,55 +17,7 @@ test('tokenize works for a good program', () => { `) + '));', { chapter: Chapter.SOURCE_4 } - ).toMatchInlineSnapshot(` - Array [ - "list(\\"function\\", - \\"f\\", - \\"(\\", - \\"x\\", - \\")\\", - \\"{\\", - \\"const\\", - \\"y\\", - \\"=\\", - \\"x\\", - \\"+\\", - \\"x\\", - \\"+\\", - \\"x\\", - \\"+\\", - \\"\\\\\\"123\\\\\\"\\", - \\";\\", - \\"return\\", - \\"z\\", - \\"=>\\", - \\"(\\", - \\"a\\", - \\",\\", - \\"b\\", - \\")\\", - \\"=>\\", - \\"{\\", - \\"let\\", - \\"w\\", - \\"=\\", - \\"z\\", - \\"+\\", - \\"1\\", - \\";\\", - \\"return\\", - \\"y\\", - \\";\\", - \\"}\\", - \\";\\", - \\"}\\", - \\"f\\", - \\"(\\", - \\"\\\\\\"55\\\\\\"\\", - \\")\\", - \\";\\")", - ] - `) + ).toMatchInlineSnapshot(`Array []`) }) test('tokenize works even with parse errors', () => { @@ -77,11 +29,7 @@ test('tokenize works even with parse errors', () => { `) + '));', { chapter: Chapter.SOURCE_4 } - ).toMatchInlineSnapshot(` - Array [ - "list(\\"function\\", \\"f\\", \\"(\\", \\"x\\", \\")\\", \\"{\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\", \\";\\")", - ] - `) + ).toMatchInlineSnapshot(`Array []`) }) test('tokenize prints suitable error when tokenization fails', () => { diff --git a/src/parser/source/index.ts b/src/parser/source/index.ts index 733bea392..9621c92d3 100644 --- a/src/parser/source/index.ts +++ b/src/parser/source/index.ts @@ -2,7 +2,8 @@ import { parse as acornParse, Token, tokenizer } from 'acorn' import * as es from 'estree' import { DEFAULT_ECMA_VERSION } from '../../constants' -import { Chapter, Context, Node, Rule, SourceError, Variant } from '../../types' +import { Chapter, Context, Node, SourceError, Variant } from '../../types' +import { Rule } from '../types' import { ancestor, AncestorWalkerFn } from '../../utils/walkers' import { DisallowedConstructError, FatalSyntaxError } from '../errors' import { AcornOptions, Parser } from '../types' diff --git a/src/parser/source/rules/index.ts b/src/parser/source/rules/index.ts index 241307b9f..3b476c248 100644 --- a/src/parser/source/rules/index.ts +++ b/src/parser/source/rules/index.ts @@ -1,4 +1,5 @@ -import { Node, Rule } from '../../../types' +import { Node } from '../../../types' +import { Rule } from '../../types' import bracesAroundFor from './bracesAroundFor' import bracesAroundIfElse from './bracesAroundIfElse' import bracesAroundWhile from './bracesAroundWhile' diff --git a/src/parser/source/rules/noExportNamedDeclarationWithDefault.ts b/src/parser/source/rules/noExportNamedDeclarationWithDefault.ts index f38be0681..f30ffc959 100644 --- a/src/parser/source/rules/noExportNamedDeclarationWithDefault.ts +++ b/src/parser/source/rules/noExportNamedDeclarationWithDefault.ts @@ -1,22 +1,12 @@ -import * as es from 'estree' - -import { UNKNOWN_LOCATION } from '../../../constants' +import type { ExportNamedDeclaration } from 'estree' import { defaultExportLookupName } from '../../../stdlib/localImport.prelude' -import { ErrorSeverity, ErrorType, Node, Rule, SourceError } from '../../../types' +import type { Rule } from '../../types' import syntaxBlacklist from '../syntax' +import { RuleError } from '../../errors' -export class NoExportNamedDeclarationWithDefaultError implements SourceError { - public type = ErrorType.SYNTAX - public severity = ErrorSeverity.ERROR - - constructor(public node: es.ExportNamedDeclaration) {} - - get location() { - return this.node.loc ?? UNKNOWN_LOCATION - } - +export class NoExportNamedDeclarationWithDefaultError extends RuleError { public explain() { - return 'Export default declarations are not allowed' + return 'Export default declarations are not allowed.' } public elaborate() { @@ -24,14 +14,17 @@ export class NoExportNamedDeclarationWithDefaultError implements SourceError { } } -const noExportNamedDeclarationWithDefault: Rule = { +const noExportNamedDeclarationWithDefault: Rule = { name: 'no-declare-mutable', disableFromChapter: syntaxBlacklist['ExportDefaultDeclaration'], - + testSnippets: [ + ['const x = 0; export { x };'], + ['const x = 0; export { x as default };', 'Export default declarations are not allowed.'] + ], checkers: { - ExportNamedDeclaration(node: es.ExportNamedDeclaration, _ancestors: [Node]) { + ExportNamedDeclaration(node) { const errors: NoExportNamedDeclarationWithDefaultError[] = [] - node.specifiers.forEach((specifier: es.ExportSpecifier) => { + node.specifiers.forEach(specifier => { if (specifier.exported.name === defaultExportLookupName) { errors.push(new NoExportNamedDeclarationWithDefaultError(node)) } diff --git a/src/parser/source/rules/noExportNamedDeclarationWithSource.ts b/src/parser/source/rules/noExportNamedDeclarationWithSource.ts new file mode 100644 index 000000000..ad27e22c5 --- /dev/null +++ b/src/parser/source/rules/noExportNamedDeclarationWithSource.ts @@ -0,0 +1,33 @@ +import type { ExportNamedDeclaration } from 'estree' +import type { Rule } from '../../types' +import { RuleError } from '../../errors' + +export class NoExportNamedDeclarationWithSourceError extends RuleError { + public explain() { + return "Exports of the form 'export { a } from './file.js' are not allowed!" + } + + public elaborate() { + return 'Import your desired object first, then re-export it, like this:' + } +} + +const noExportNamedDeclarationWithDefault = { + name: 'no-export-declaration-with-source', + testSnippets: [ + [ + 'export { hi } from "./somewhere.js"', + "Exports of the form 'export { a } from './file.js' are not allowed!" + ], + ['const x = 0; export { x };'] + ], + checkers: { + ExportNamedDeclaration(node) { + if (node.source !== null) { + return [new NoExportNamedDeclarationWithSourceError(node)] + } + return [] + } + } +} satisfies Rule +export default noExportNamedDeclarationWithDefault diff --git a/src/parser/source/rules/noTemplateExpression.ts b/src/parser/source/rules/noTemplateExpression.ts index dd870fe6c..aa8193846 100644 --- a/src/parser/source/rules/noTemplateExpression.ts +++ b/src/parser/source/rules/noTemplateExpression.ts @@ -1,18 +1,8 @@ -import * as es from 'estree' - -import { UNKNOWN_LOCATION } from '../../../constants' -import { ErrorSeverity, ErrorType, Node, Rule, SourceError } from '../../../types' - -export class NoTemplateExpressionError implements SourceError { - public type = ErrorType.SYNTAX - public severity = ErrorSeverity.ERROR - - constructor(public node: es.TemplateLiteral) {} - - get location() { - return this.node.loc ?? UNKNOWN_LOCATION - } +import type { TemplateLiteral } from 'estree' +import { RuleError } from '../../errors' +import type { Rule } from '../../types' +export class NoTemplateExpressionError extends RuleError { public explain() { return 'Expressions are not allowed in template literals (`multiline strings`)' } @@ -22,11 +12,14 @@ export class NoTemplateExpressionError implements SourceError { } } -const noTemplateExpression: Rule = { +const noTemplateExpression: Rule = { name: 'no-template-expression', - + testSnippets: [ + ['const x = `a\nb`;'], + ['const x = `${0}`', 'Expressions are not allowed in template literals (`multiline strings`)'] + ], checkers: { - TemplateLiteral(node: es.TemplateLiteral, _ancestors: [Node]) { + TemplateLiteral(node) { if (node.expressions.length > 0) { return [new NoTemplateExpressionError(node)] } else { diff --git a/src/repl/__tests__/__snapshots__/svmc.ts.snap b/src/repl/__tests__/__snapshots__/svmc.ts.snap new file mode 100644 index 000000000..5819b1c48 --- /dev/null +++ b/src/repl/__tests__/__snapshots__/svmc.ts.snap @@ -0,0 +1,138 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Test output options ast 1`] = ` +"{ + \\"type\\": \\"Program\\", + \\"start\\": 0, + \\"end\\": 4, + \\"loc\\": { + \\"start\\": { + \\"line\\": 1, + \\"column\\": 0 + }, + \\"end\\": { + \\"line\\": 1, + \\"column\\": 4 + } + }, + \\"body\\": [ + { + \\"type\\": \\"ExpressionStatement\\", + \\"start\\": 0, + \\"end\\": 4, + \\"loc\\": { + \\"start\\": { + \\"line\\": 1, + \\"column\\": 0 + }, + \\"end\\": { + \\"line\\": 1, + \\"column\\": 4 + } + }, + \\"expression\\": { + \\"type\\": \\"BinaryExpression\\", + \\"start\\": 0, + \\"end\\": 3, + \\"loc\\": { + \\"start\\": { + \\"line\\": 1, + \\"column\\": 0 + }, + \\"end\\": { + \\"line\\": 1, + \\"column\\": 3 + } + }, + \\"left\\": { + \\"type\\": \\"Literal\\", + \\"start\\": 0, + \\"end\\": 1, + \\"loc\\": { + \\"start\\": { + \\"line\\": 1, + \\"column\\": 0 + }, + \\"end\\": { + \\"line\\": 1, + \\"column\\": 1 + } + }, + \\"value\\": 1, + \\"raw\\": \\"1\\" + }, + \\"operator\\": \\"+\\", + \\"right\\": { + \\"type\\": \\"Literal\\", + \\"start\\": 2, + \\"end\\": 3, + \\"loc\\": { + \\"start\\": { + \\"line\\": 1, + \\"column\\": 2 + }, + \\"end\\": { + \\"line\\": 1, + \\"column\\": 3 + } + }, + \\"value\\": 1, + \\"raw\\": \\"1\\" + } + } + } + ], + \\"sourceType\\": \\"module\\" +}" +`; + +exports[`Test output options binary 1`] = ` +Uint8Array [ + 173, + 172, + 5, + 80, + 0, + 0, + 0, + 0, + 16, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2, + 0, + 0, + 0, + 2, + 1, + 0, + 0, + 0, + 2, + 1, + 0, + 0, + 0, + 17, + 70, +] +`; + +exports[`Test output options debug 1`] = ` +"Entry function: 0 +#0: +Stack Size: 2 +Env Size: 0 +Num Args: 0 +0: LGCI 1 +1: LGCI 1 +2: ADDG +3: RETG" +`; + +exports[`Test output options json 1`] = `"[0,[[2,0,0,[[2,1],[2,1],[17],[70]]]]]"`; diff --git a/src/repl/__tests__/__snapshots__/transpiler.ts.snap b/src/repl/__tests__/__snapshots__/transpiler.ts.snap new file mode 100644 index 000000000..b5bc8b6a8 --- /dev/null +++ b/src/repl/__tests__/__snapshots__/transpiler.ts.snap @@ -0,0 +1,199 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Nothing should be written to disk if no output file was specified 1`] = ` +"{ + const get_time = nativeStorage.builtins.get(\\"get_time\\"); + const display = nativeStorage.builtins.get(\\"display\\"); + const raw_display = nativeStorage.builtins.get(\\"raw_display\\"); + const stringify = nativeStorage.builtins.get(\\"stringify\\"); + const error = nativeStorage.builtins.get(\\"error\\"); + const prompt = nativeStorage.builtins.get(\\"prompt\\"); + const is_number = nativeStorage.builtins.get(\\"is_number\\"); + const is_string = nativeStorage.builtins.get(\\"is_string\\"); + const is_function = nativeStorage.builtins.get(\\"is_function\\"); + const is_boolean = nativeStorage.builtins.get(\\"is_boolean\\"); + const is_undefined = nativeStorage.builtins.get(\\"is_undefined\\"); + const parse_int = nativeStorage.builtins.get(\\"parse_int\\"); + const char_at = nativeStorage.builtins.get(\\"char_at\\"); + const arity = nativeStorage.builtins.get(\\"arity\\"); + const undefined = nativeStorage.builtins.get(\\"undefined\\"); + const NaN = nativeStorage.builtins.get(\\"NaN\\"); + const Infinity = nativeStorage.builtins.get(\\"Infinity\\"); + const math_abs = nativeStorage.builtins.get(\\"math_abs\\"); + const math_acos = nativeStorage.builtins.get(\\"math_acos\\"); + const math_acosh = nativeStorage.builtins.get(\\"math_acosh\\"); + const math_asin = nativeStorage.builtins.get(\\"math_asin\\"); + const math_asinh = nativeStorage.builtins.get(\\"math_asinh\\"); + const math_atan = nativeStorage.builtins.get(\\"math_atan\\"); + const math_atanh = nativeStorage.builtins.get(\\"math_atanh\\"); + const math_atan2 = nativeStorage.builtins.get(\\"math_atan2\\"); + const math_ceil = nativeStorage.builtins.get(\\"math_ceil\\"); + const math_cbrt = nativeStorage.builtins.get(\\"math_cbrt\\"); + const math_expm1 = nativeStorage.builtins.get(\\"math_expm1\\"); + const math_clz32 = nativeStorage.builtins.get(\\"math_clz32\\"); + const math_cos = nativeStorage.builtins.get(\\"math_cos\\"); + const math_cosh = nativeStorage.builtins.get(\\"math_cosh\\"); + const math_exp = nativeStorage.builtins.get(\\"math_exp\\"); + const math_floor = nativeStorage.builtins.get(\\"math_floor\\"); + const math_fround = nativeStorage.builtins.get(\\"math_fround\\"); + const math_hypot = nativeStorage.builtins.get(\\"math_hypot\\"); + const math_imul = nativeStorage.builtins.get(\\"math_imul\\"); + const math_log = nativeStorage.builtins.get(\\"math_log\\"); + const math_log1p = nativeStorage.builtins.get(\\"math_log1p\\"); + const math_log2 = nativeStorage.builtins.get(\\"math_log2\\"); + const math_log10 = nativeStorage.builtins.get(\\"math_log10\\"); + const math_max = nativeStorage.builtins.get(\\"math_max\\"); + const math_min = nativeStorage.builtins.get(\\"math_min\\"); + const math_pow = nativeStorage.builtins.get(\\"math_pow\\"); + const math_random = nativeStorage.builtins.get(\\"math_random\\"); + const math_round = nativeStorage.builtins.get(\\"math_round\\"); + const math_sign = nativeStorage.builtins.get(\\"math_sign\\"); + const math_sin = nativeStorage.builtins.get(\\"math_sin\\"); + const math_sinh = nativeStorage.builtins.get(\\"math_sinh\\"); + const math_sqrt = nativeStorage.builtins.get(\\"math_sqrt\\"); + const math_tan = nativeStorage.builtins.get(\\"math_tan\\"); + const math_tanh = nativeStorage.builtins.get(\\"math_tanh\\"); + const math_trunc = nativeStorage.builtins.get(\\"math_trunc\\"); + const math_E = nativeStorage.builtins.get(\\"math_E\\"); + const math_LN10 = nativeStorage.builtins.get(\\"math_LN10\\"); + const math_LN2 = nativeStorage.builtins.get(\\"math_LN2\\"); + const math_LOG10E = nativeStorage.builtins.get(\\"math_LOG10E\\"); + const math_LOG2E = nativeStorage.builtins.get(\\"math_LOG2E\\"); + const math_PI = nativeStorage.builtins.get(\\"math_PI\\"); + const math_SQRT1_2 = nativeStorage.builtins.get(\\"math_SQRT1_2\\"); + const math_SQRT2 = nativeStorage.builtins.get(\\"math_SQRT2\\"); + const pair = nativeStorage.builtins.get(\\"pair\\"); + const is_pair = nativeStorage.builtins.get(\\"is_pair\\"); + const head = nativeStorage.builtins.get(\\"head\\"); + const tail = nativeStorage.builtins.get(\\"tail\\"); + const is_null = nativeStorage.builtins.get(\\"is_null\\"); + const list = nativeStorage.builtins.get(\\"list\\"); + const draw_data = nativeStorage.builtins.get(\\"draw_data\\"); + const display_list = nativeStorage.builtins.get(\\"display_list\\"); + const is_list = nativeStorage.builtins.get(\\"is_list\\"); + const set_head = nativeStorage.builtins.get(\\"set_head\\"); + const set_tail = nativeStorage.builtins.get(\\"set_tail\\"); + const array_length = nativeStorage.builtins.get(\\"array_length\\"); + const is_array = nativeStorage.builtins.get(\\"is_array\\"); + const stream = nativeStorage.builtins.get(\\"stream\\"); + const parse = nativeStorage.builtins.get(\\"parse\\"); + const tokenize = nativeStorage.builtins.get(\\"tokenize\\"); + const apply_in_underlying_javascript = nativeStorage.builtins.get(\\"apply_in_underlying_javascript\\"); + const call_cc = nativeStorage.builtins.get(\\"call_cc\\"); + { + const native = nativeStorage; + const callIfFuncAndRightArgs = native.operators.get(\\"callIfFuncAndRightArgs\\"); + const boolOrErr = native.operators.get(\\"boolOrErr\\"); + const wrap = native.operators.get(\\"wrap\\"); + const unaryOp = native.operators.get(\\"unaryOp\\"); + const binaryOp = native.operators.get(\\"binaryOp\\"); + const throwIfTimeout = native.operators.get(\\"throwIfTimeout\\"); + const setProp = native.operators.get(\\"setProp\\"); + const getProp = native.operators.get(\\"getProp\\"); + const builtins = native.operators.get(\\"builtins\\"); + native.evaller = program => eval(program); + undefined; + binaryOp(\\"+\\", 4, 1, 1, 1, 0, \\"/Users/henz/Repos/SourceAcademy/js-slang/test.js\\"); + } +} +" +`; + +exports[`Writing to file 1`] = ` +"{ + const get_time = nativeStorage.builtins.get(\\"get_time\\"); + const display = nativeStorage.builtins.get(\\"display\\"); + const raw_display = nativeStorage.builtins.get(\\"raw_display\\"); + const stringify = nativeStorage.builtins.get(\\"stringify\\"); + const error = nativeStorage.builtins.get(\\"error\\"); + const prompt = nativeStorage.builtins.get(\\"prompt\\"); + const is_number = nativeStorage.builtins.get(\\"is_number\\"); + const is_string = nativeStorage.builtins.get(\\"is_string\\"); + const is_function = nativeStorage.builtins.get(\\"is_function\\"); + const is_boolean = nativeStorage.builtins.get(\\"is_boolean\\"); + const is_undefined = nativeStorage.builtins.get(\\"is_undefined\\"); + const parse_int = nativeStorage.builtins.get(\\"parse_int\\"); + const char_at = nativeStorage.builtins.get(\\"char_at\\"); + const arity = nativeStorage.builtins.get(\\"arity\\"); + const undefined = nativeStorage.builtins.get(\\"undefined\\"); + const NaN = nativeStorage.builtins.get(\\"NaN\\"); + const Infinity = nativeStorage.builtins.get(\\"Infinity\\"); + const math_abs = nativeStorage.builtins.get(\\"math_abs\\"); + const math_acos = nativeStorage.builtins.get(\\"math_acos\\"); + const math_acosh = nativeStorage.builtins.get(\\"math_acosh\\"); + const math_asin = nativeStorage.builtins.get(\\"math_asin\\"); + const math_asinh = nativeStorage.builtins.get(\\"math_asinh\\"); + const math_atan = nativeStorage.builtins.get(\\"math_atan\\"); + const math_atanh = nativeStorage.builtins.get(\\"math_atanh\\"); + const math_atan2 = nativeStorage.builtins.get(\\"math_atan2\\"); + const math_ceil = nativeStorage.builtins.get(\\"math_ceil\\"); + const math_cbrt = nativeStorage.builtins.get(\\"math_cbrt\\"); + const math_expm1 = nativeStorage.builtins.get(\\"math_expm1\\"); + const math_clz32 = nativeStorage.builtins.get(\\"math_clz32\\"); + const math_cos = nativeStorage.builtins.get(\\"math_cos\\"); + const math_cosh = nativeStorage.builtins.get(\\"math_cosh\\"); + const math_exp = nativeStorage.builtins.get(\\"math_exp\\"); + const math_floor = nativeStorage.builtins.get(\\"math_floor\\"); + const math_fround = nativeStorage.builtins.get(\\"math_fround\\"); + const math_hypot = nativeStorage.builtins.get(\\"math_hypot\\"); + const math_imul = nativeStorage.builtins.get(\\"math_imul\\"); + const math_log = nativeStorage.builtins.get(\\"math_log\\"); + const math_log1p = nativeStorage.builtins.get(\\"math_log1p\\"); + const math_log2 = nativeStorage.builtins.get(\\"math_log2\\"); + const math_log10 = nativeStorage.builtins.get(\\"math_log10\\"); + const math_max = nativeStorage.builtins.get(\\"math_max\\"); + const math_min = nativeStorage.builtins.get(\\"math_min\\"); + const math_pow = nativeStorage.builtins.get(\\"math_pow\\"); + const math_random = nativeStorage.builtins.get(\\"math_random\\"); + const math_round = nativeStorage.builtins.get(\\"math_round\\"); + const math_sign = nativeStorage.builtins.get(\\"math_sign\\"); + const math_sin = nativeStorage.builtins.get(\\"math_sin\\"); + const math_sinh = nativeStorage.builtins.get(\\"math_sinh\\"); + const math_sqrt = nativeStorage.builtins.get(\\"math_sqrt\\"); + const math_tan = nativeStorage.builtins.get(\\"math_tan\\"); + const math_tanh = nativeStorage.builtins.get(\\"math_tanh\\"); + const math_trunc = nativeStorage.builtins.get(\\"math_trunc\\"); + const math_E = nativeStorage.builtins.get(\\"math_E\\"); + const math_LN10 = nativeStorage.builtins.get(\\"math_LN10\\"); + const math_LN2 = nativeStorage.builtins.get(\\"math_LN2\\"); + const math_LOG10E = nativeStorage.builtins.get(\\"math_LOG10E\\"); + const math_LOG2E = nativeStorage.builtins.get(\\"math_LOG2E\\"); + const math_PI = nativeStorage.builtins.get(\\"math_PI\\"); + const math_SQRT1_2 = nativeStorage.builtins.get(\\"math_SQRT1_2\\"); + const math_SQRT2 = nativeStorage.builtins.get(\\"math_SQRT2\\"); + const pair = nativeStorage.builtins.get(\\"pair\\"); + const is_pair = nativeStorage.builtins.get(\\"is_pair\\"); + const head = nativeStorage.builtins.get(\\"head\\"); + const tail = nativeStorage.builtins.get(\\"tail\\"); + const is_null = nativeStorage.builtins.get(\\"is_null\\"); + const list = nativeStorage.builtins.get(\\"list\\"); + const draw_data = nativeStorage.builtins.get(\\"draw_data\\"); + const display_list = nativeStorage.builtins.get(\\"display_list\\"); + const is_list = nativeStorage.builtins.get(\\"is_list\\"); + const set_head = nativeStorage.builtins.get(\\"set_head\\"); + const set_tail = nativeStorage.builtins.get(\\"set_tail\\"); + const array_length = nativeStorage.builtins.get(\\"array_length\\"); + const is_array = nativeStorage.builtins.get(\\"is_array\\"); + const stream = nativeStorage.builtins.get(\\"stream\\"); + const parse = nativeStorage.builtins.get(\\"parse\\"); + const tokenize = nativeStorage.builtins.get(\\"tokenize\\"); + const apply_in_underlying_javascript = nativeStorage.builtins.get(\\"apply_in_underlying_javascript\\"); + const call_cc = nativeStorage.builtins.get(\\"call_cc\\"); + { + const native = nativeStorage; + const callIfFuncAndRightArgs = native.operators.get(\\"callIfFuncAndRightArgs\\"); + const boolOrErr = native.operators.get(\\"boolOrErr\\"); + const wrap = native.operators.get(\\"wrap\\"); + const unaryOp = native.operators.get(\\"unaryOp\\"); + const binaryOp = native.operators.get(\\"binaryOp\\"); + const throwIfTimeout = native.operators.get(\\"throwIfTimeout\\"); + const setProp = native.operators.get(\\"setProp\\"); + const getProp = native.operators.get(\\"getProp\\"); + const builtins = native.operators.get(\\"builtins\\"); + native.evaller = program => eval(program); + undefined; + binaryOp(\\"+\\", 4, 1, 1, 1, 0, \\"/Users/henz/Repos/SourceAcademy/js-slang/test.js\\"); + } +} +" +`; diff --git a/src/repl/__tests__/main.ts b/src/repl/__tests__/main.ts new file mode 100644 index 000000000..421e136e8 --- /dev/null +++ b/src/repl/__tests__/main.ts @@ -0,0 +1,20 @@ +import type { Command } from 'commander' +import { getMainCommand } from '../main' + +jest.spyOn(process, 'exit').mockImplementation(code => { + throw new Error(`process.exit called with ${code}`) +}) + +jest.spyOn(process.stdout, 'write').mockImplementation(() => true) + +describe('Make sure each subcommand can be run', () => { + const mainCommand = getMainCommand() + test.each(mainCommand.commands.map(cmd => [cmd.name(), cmd] as [string, Command]))( + 'Testing %s command', + (_, cmd) => { + return expect(cmd.parseAsync(['-h'], { from: 'user' })).rejects.toMatchInlineSnapshot( + '[Error: process.exit called with 0]' + ) + } + ) +}) diff --git a/src/repl/__tests__/repl.ts b/src/repl/__tests__/repl.ts index b3276464d..3b1bf04b4 100644 --- a/src/repl/__tests__/repl.ts +++ b/src/repl/__tests__/repl.ts @@ -1,7 +1,7 @@ import * as repl from 'repl' import type { SourceFiles } from '../../modules/moduleTypes' import { Chapter } from '../../types' -import { asMockedFunc } from '../../utils/testing' +import { asMockedFunc } from '../../utils/testing/misc' import { getReplCommand } from '../repl' import { chapterParser } from '../utils' diff --git a/src/repl/__tests__/svmc.ts b/src/repl/__tests__/svmc.ts new file mode 100644 index 000000000..a248f6a50 --- /dev/null +++ b/src/repl/__tests__/svmc.ts @@ -0,0 +1,93 @@ +import * as fs from 'fs/promises' +import { asMockedFunc } from '../../utils/testing/misc' +import { compileToChoices, getSVMCCommand } from '../svmc' +import * as vm from '../../vm/svml-compiler' +import { expectWritten, getCommandRunner } from './utils' + +jest.mock('fs/promises', () => ({ + writeFile: jest.fn(), + readFile: jest.fn() +})) + +const mockedReadFile = asMockedFunc(fs.readFile) +const mockedWriteFile = asMockedFunc(fs.writeFile) + +jest.spyOn(vm, 'compileToIns') + +beforeEach(() => { + jest.clearAllMocks() +}) + +const { expectError: rawExpectError, expectSuccess: rawExpectSuccess } = + getCommandRunner(getSVMCCommand) + +async function expectSuccess(code: string, ...args: string[]) { + mockedReadFile.mockResolvedValueOnce(code) + + await rawExpectSuccess(...args) + expect(fs.readFile).toHaveBeenCalledTimes(1) + expect(fs.writeFile).toHaveBeenCalledTimes(1) +} + +function expectError(code: string, ...args: string[]) { + mockedReadFile.mockResolvedValueOnce(code) + return rawExpectError(...args) +} + +test('Running with defaults', async () => { + await expectSuccess('1+1;', 'test.js') + + const [[fileName]] = mockedWriteFile.mock.calls + expect(fileName).toEqual('test.svm') +}) + +it("won't run if the program has parsing errors", async () => { + await expectError('1 + 1', '/test.js') + expect(vm.compileToIns).toHaveBeenCalledTimes(0) + expectWritten(process.stderr.write).toMatchInlineSnapshot( + `"Line 1: Missing semicolon at the end of statement"` + ) +}) + +it("won't perform compilation if the output type is 'ast'", async () => { + await expectSuccess('1+1;', 'test.js', '-t', 'ast') + expect(vm.compileToIns).toHaveBeenCalledTimes(0) +}) + +describe('--internals option', () => { + test('with valid values', async () => { + await expectSuccess('1+1;', 'test.js', '--internals', '["func1", "func2"]') + expect(vm.compileToIns).toHaveBeenCalledTimes(1) + const [[, , internals]] = asMockedFunc(vm.compileToIns).mock.calls + + expect(internals).toEqual(['func1', 'func2']) + }) + + test('with non-string values in array', async () => { + await expectError('1+1;', 'test.js', '--internals', '[1, 2]') + expectWritten(process.stderr.write).toMatchInlineSnapshot(` + "error: option '-i, --internals ' argument '[1, 2]' is invalid. Expected a JSON array of strings! + " + `) + }) + + test('with a non-array', async () => { + await expectError('1+1;', 'test.js', '--internals', '{ "a": 1, "b": 2}') + expectWritten(process.stderr.write).toMatchInlineSnapshot(` + "error: option '-i, --internals ' argument '{ \\"a\\": 1, \\"b\\": 2}' is invalid. Expected a JSON array of strings! + " + `) + }) +}) + +describe('Test output options', () => { + compileToChoices.forEach(choice => { + test(choice, async () => { + await expectSuccess('1 + 1;', 'test.js', '-t', choice) + const [[fileName, contents]] = mockedWriteFile.mock.calls + + expect((fileName as string).startsWith('test')).toEqual(true) + expect(contents).toMatchSnapshot() + }) + }) +}) diff --git a/src/repl/__tests__/transpiler.ts b/src/repl/__tests__/transpiler.ts new file mode 100644 index 000000000..753f98cb3 --- /dev/null +++ b/src/repl/__tests__/transpiler.ts @@ -0,0 +1,66 @@ +import { asMockedFunc } from '../../utils/testing/misc' +import { getTranspilerCommand } from '../transpiler' +import * as fs from 'fs/promises' +import { expectWritten, getCommandRunner } from './utils' + +jest.mock('fs/promises', () => ({ + readFile: jest.fn(), + writeFile: jest.fn() +})) + +beforeEach(() => { + jest.clearAllMocks() +}) + +const mockedWriteFile = asMockedFunc(fs.writeFile) +const mockedReadFile = asMockedFunc(fs.readFile) +const { expectError, expectSuccess } = getCommandRunner(getTranspilerCommand) + +test('Nothing should be written if the program has parser errors', async () => { + mockedReadFile.mockResolvedValueOnce('1+1') + await expectError('/test.js') + expect(fs.writeFile).toHaveBeenCalledTimes(0) + + expectWritten(process.stderr.write).toMatchInlineSnapshot( + `"[/test.js] Line 1: Missing semicolon at the end of statement"` + ) +}) + +test('Nothing should be written if the program has transpiler errors', async () => { + mockedReadFile.mockResolvedValueOnce('a;') + await expectError('/test.js') + expect(fs.writeFile).toHaveBeenCalledTimes(0) + + expectWritten(process.stderr.write).toMatchInlineSnapshot( + `"[/test.js] Line 1: Name a not declared."` + ) +}) + +test('Nothing should be written to disk if no output file was specified', async () => { + mockedReadFile.mockResolvedValueOnce('1+1;') + await expectSuccess('test.js') + expect(fs.writeFile).toHaveBeenCalledTimes(0) + + // Code should have been written to stdout + expectWritten(process.stdout.write).toMatchSnapshot() +}) + +test('Writing to file', async () => { + mockedReadFile.mockResolvedValueOnce('1+1;') + await expectSuccess('test.js', '-o', 'out.js') + expect(fs.writeFile).toHaveBeenCalledTimes(1) + + const [[fileName, contents]] = mockedWriteFile.mock.calls + expect(fileName).toEqual('out.js') + expect(contents).toMatchSnapshot() +}) + +test('pretranspile option', async () => { + mockedReadFile.mockResolvedValueOnce('1+1;') + await expectSuccess('test.js', '-o', 'out.js', '-p') + expect(fs.writeFile).toHaveBeenCalledTimes(1) + + const [[fileName, contents]] = mockedWriteFile.mock.calls + expect(fileName).toEqual('out.js') + expect(contents).toEqual('1 + 1;\n') +}) diff --git a/src/repl/__tests__/utils.ts b/src/repl/__tests__/utils.ts new file mode 100644 index 000000000..fb944018e --- /dev/null +++ b/src/repl/__tests__/utils.ts @@ -0,0 +1,38 @@ +import type { Command } from '@commander-js/extra-typings' +import { asMockedFunc } from '../../utils/testing/misc' + +/** + * Set up the environment for testing the given command. Returns + * `expectSuccess` and `expectError` for use with making assertions + * about the behaviour of the command + */ +export function getCommandRunner>(getter: () => T) { + jest.spyOn(process.stdout, 'write').mockImplementation(() => true) + jest.spyOn(process.stderr, 'write').mockImplementation(() => true) + jest.spyOn(process, 'exit').mockImplementation(code => { + throw new Error(`process.exit called with ${code}`) + }) + + async function runner(...args: string[]) { + await getter().parseAsync(args, { from: 'user' }) + } + + return { + expectError(...args: string[]) { + // Error conditions should always cause commands to call + // process.exit(1) + return expect(runner(...args)).rejects.toMatchInlineSnapshot( + `[Error: process.exit called with 1]` + ) + }, + expectSuccess(...args: string[]) { + return expect(runner(...args)).resolves.toBeUndefined() + } + } +} + +export function expectWritten(f: (contents: string) => any) { + expect(f).toHaveBeenCalledTimes(1) + const [[contents]] = asMockedFunc(f).mock.calls + return expect(contents) +} diff --git a/src/repl/index.ts b/src/repl/index.ts index 72065bc95..a1c7aefd7 100644 --- a/src/repl/index.ts +++ b/src/repl/index.ts @@ -1,11 +1,4 @@ -#!/usr/bin/env node +#!/bin/env/node +import { getMainCommand } from './main' -import { Command } from '@commander-js/extra-typings' - -import { getReplCommand } from './repl' -import { transpilerCommand } from './transpiler' - -new Command() - .addCommand(transpilerCommand) - .addCommand(getReplCommand(), { isDefault: true }) - .parseAsync() +getMainCommand().parseAsync() diff --git a/src/repl/main.ts b/src/repl/main.ts new file mode 100644 index 000000000..6ca6834ae --- /dev/null +++ b/src/repl/main.ts @@ -0,0 +1,11 @@ +import { Command } from '@commander-js/extra-typings' + +import { getSVMCCommand } from './svmc' +import { getReplCommand } from './repl' +import { getTranspilerCommand } from './transpiler' + +export const getMainCommand = () => + new Command() + .addCommand(getSVMCCommand()) + .addCommand(getTranspilerCommand()) + .addCommand(getReplCommand(), { isDefault: true }) diff --git a/src/repl/svmc.ts b/src/repl/svmc.ts new file mode 100644 index 000000000..5cba0dd37 --- /dev/null +++ b/src/repl/svmc.ts @@ -0,0 +1,106 @@ +import type pathlib from 'path' +import type fslib from 'fs/promises' + +import { Command, InvalidArgumentError, Option } from '@commander-js/extra-typings' +import { createEmptyContext } from '../createContext' +import { parse } from '../parser/parser' +import { Chapter, Variant } from '../types' +import { stripIndent } from '../utils/formatters' +import { parseError } from '..' +import { assemble } from '../vm/svml-assembler' +import { compileToIns } from '../vm/svml-compiler' +import { stringifyProgram } from '../vm/util' +import { chapterParser, getChapterOption } from './utils' + +export const compileToChoices = ['ast', 'binary', 'debug', 'json'] as const + +export const getSVMCCommand = () => + new Command('svmc') + .argument('', 'File to read code from') + .addOption(getChapterOption(Chapter.SOURCE_3, chapterParser)) + .addOption( + new Option( + '-t, --compileTo ', + stripIndent` + json: Compile only, but don't assemble. + binary: Compile and assemble. + debug: Compile and pretty-print the compiler output. For debugging the compiler. + ast: Parse and pretty-print the AST. For debugging the parser.` + ) + .choices(compileToChoices) + .default('binary' as (typeof compileToChoices)[number]) + ) + .option( + '-o, --out ', + stripIndent` + Sets the output filename. + Defaults to the input filename, minus any file extension, plus '.svm'. + ` + ) + .addOption( + new Option( + '-i, --internals ', + `Sets the list of VM-internal functions. The argument should be a JSON array of +strings containing the names of the VM-internal functions.` + ) + .argParser(value => { + const parsed = JSON.parse(value) + if (!Array.isArray(parsed)) { + throw new InvalidArgumentError('Expected a JSON array of strings!') + } + + for (const each of parsed) { + if (typeof each !== 'string') { + throw new InvalidArgumentError('Expected a JSON array of strings!') + } + } + return parsed as string[] + }) + .default([] as string[]) + ) + .action(async (inputFile, opts) => { + const fs: typeof fslib = require('fs/promises') + const vmInternalFunctions = opts.internals || [] + + const source = await fs.readFile(inputFile, 'utf-8') + const context = createEmptyContext(opts.chapter, Variant.DEFAULT, [], null) + const program = parse(source, context) + if (program === null) { + process.stderr.write(parseError(context.errors)) + process.exit(1) + } + + let output: string | Uint8Array + let ext: string + + if (opts.compileTo === 'ast') { + output = JSON.stringify(program, undefined, 2) + ext = '.json' + } else { + const compiled = compileToIns(program, undefined, vmInternalFunctions) + switch (opts.compileTo) { + case 'debug': { + output = stringifyProgram(compiled).trimEnd() + ext = '.svm' + break + } + case 'json': { + output = JSON.stringify(compiled) + ext = '.json' + break + } + case 'binary': { + output = assemble(compiled) + ext = '.svm' + break + } + } + } + + const { extname, basename }: typeof pathlib = require('path') + const extToRemove = extname(inputFile) + + const outputFileName = opts.out ?? `${basename(inputFile, extToRemove)}${ext}` + await fs.writeFile(outputFileName, output) + console.log(`Output written to ${outputFileName}`) + }) diff --git a/src/repl/transpiler.ts b/src/repl/transpiler.ts index 0f4884d1c..a65edfc30 100644 --- a/src/repl/transpiler.ts +++ b/src/repl/transpiler.ts @@ -16,63 +16,60 @@ import { validateChapterAndVariantCombo } from './utils' -export const transpilerCommand = new Command('transpiler') - .addOption(getVariantOption(Variant.DEFAULT, [Variant.DEFAULT, Variant.NATIVE])) - .addOption(getChapterOption(Chapter.SOURCE_4, chapterParser)) - .option( - '-p, --pretranspile', - "only pretranspile (e.g. GPU -> Source) and don't perform Source -> JS transpilation" - ) - .option('-o, --out ', 'Specify a file to write to') - .argument('') - .action(async (fileName, opts) => { - if (!validateChapterAndVariantCombo(opts)) { - console.log('Invalid language combination!') - return - } +export const getTranspilerCommand = () => + new Command('transpiler') + .addOption(getVariantOption(Variant.DEFAULT, [Variant.DEFAULT, Variant.NATIVE])) + .addOption(getChapterOption(Chapter.SOURCE_4, chapterParser)) + .option('-p, --pretranspile', "only pretranspile and don't perform Source -> JS transpilation") + .option('-o, --out ', 'Specify a file to write to') + .argument('') + .action(async (fileName, opts) => { + if (!validateChapterAndVariantCombo(opts)) { + console.log('Invalid language combination!') + return + } - const fs: typeof fslib = require('fs/promises') - const context = createContext(opts.chapter, opts.variant) - const entrypointFilePath = resolve(fileName) + const fs: typeof fslib = require('fs/promises') + const context = createContext(opts.chapter, opts.variant) + const entrypointFilePath = resolve(fileName) - const linkerResult = await parseProgramsAndConstructImportGraph( - async p => { - try { - const text = await fs.readFile(p, 'utf-8') - return text - } catch (error) { - if (error.code === 'ENOENT') return undefined - throw error - } - }, - entrypointFilePath, - context, - {}, - true - ) - - if (!linkerResult.ok) { - console.log(parseError(context.errors, linkerResult.verboseErrors)) - return - } + const linkerResult = await parseProgramsAndConstructImportGraph( + async p => { + try { + const text = await fs.readFile(p, 'utf-8') + return text + } catch (error) { + if (error.code === 'ENOENT') return undefined + throw error + } + }, + entrypointFilePath, + context, + {}, + true + ) - const { programs, topoOrder } = linkerResult - const bundledProgram = defaultBundler(programs, entrypointFilePath, topoOrder, context) + if (!linkerResult.ok) { + process.stderr.write(parseError(context.errors, linkerResult.verboseErrors)) + process.exit(1) + } - const transpiled = opts.pretranspile - ? generate(bundledProgram) - : transpile(bundledProgram, context).transpiled + const { programs, topoOrder } = linkerResult + const bundledProgram = defaultBundler(programs, entrypointFilePath, topoOrder, context) - if (context.errors.length > 0) { - console.log(parseError(context.errors, linkerResult.verboseErrors)) - return - } + try { + const transpiled = opts.pretranspile + ? generate(bundledProgram) + : transpile(bundledProgram, context).transpiled - if (opts.out) { - const resolvedOut = resolve(opts.out) - await fs.writeFile(resolvedOut, transpiled) - console.log(`Code written to ${resolvedOut}`) - } else { - console.log(transpiled) - } - }) + if (opts.out) { + await fs.writeFile(opts.out, transpiled) + console.log(`Code written to ${opts.out}`) + } else { + process.stdout.write(transpiled) + } + } catch (error) { + process.stderr.write(parseError([error], linkerResult.verboseErrors)) + process.exit(1) + } + }) diff --git a/src/runner/__tests__/files.ts b/src/runner/__tests__/files.ts index 4a355cd6a..cf275cd1d 100644 --- a/src/runner/__tests__/files.ts +++ b/src/runner/__tests__/files.ts @@ -1,5 +1,5 @@ import { compileFiles, parseError, runFilesInContext } from '../../index' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter } from '../../types' describe('runFilesInContext', () => { diff --git a/src/runner/__tests__/modules.ts b/src/runner/__tests__/modules.ts index 552b21e99..9f93f601b 100644 --- a/src/runner/__tests__/modules.ts +++ b/src/runner/__tests__/modules.ts @@ -1,7 +1,7 @@ -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter, Variant } from '../../types' import { stripIndent } from '../../utils/formatters' -import { expectFinishedResult } from '../../utils/testing' +import { expectFinishedResultValue } from '../../utils/testing/misc' import { runCodeInSource } from '../sourceRunner' jest.mock('../../modules/loader/loaders') @@ -67,8 +67,7 @@ describe.each(describeCases)( const context = mockContext(chapter, variant) const { result } = await runCodeInSource(code, context) - expectFinishedResult(result) - expect(result.value).toEqual('foo') + expectFinishedResultValue(result, 'foo') }) } ) diff --git a/src/runner/__tests__/runners.ts b/src/runner/__tests__/runners.ts index 05c2a6deb..b7d3a637f 100644 --- a/src/runner/__tests__/runners.ts +++ b/src/runner/__tests__/runners.ts @@ -1,12 +1,18 @@ -import { Context, Result, runInContext } from '../..' +import { type Context, type Result, runInContext } from '../..' import { UndefinedVariable } from '../../errors/errors' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { FatalSyntaxError } from '../../parser/errors' -import { Chapter, Finished, Variant } from '../../types' +import { Chapter, type Finished, type SourceError, Variant } from '../../types' import { locationDummyNode } from '../../utils/ast/astCreator' -import { CodeSnippetTestCase } from '../../utils/testing' import { htmlErrorHandlingScript } from '../htmlRunner' +interface CodeSnippetTestCase { + name: string + snippet: string + value: any + errors: SourceError[] +} + const JAVASCRIPT_CODE_SNIPPETS_NO_ERRORS: CodeSnippetTestCase[] = [ { name: 'LITERAL OBJECT', diff --git a/src/runner/sourceRunner.ts b/src/runner/sourceRunner.ts index e2e91befe..85b9d6f9f 100644 --- a/src/runner/sourceRunner.ts +++ b/src/runner/sourceRunner.ts @@ -3,19 +3,17 @@ import * as _ from 'lodash' import type { RawSourceMap } from 'source-map' import { type IOptions, type Result } from '..' -import { JSSLANG_PROPERTIES, UNKNOWN_LOCATION } from '../constants' +import { JSSLANG_PROPERTIES } from '../constants' import { CSEResultPromise, evaluate as CSEvaluate } from '../cse-machine/interpreter' import { ExceptionError } from '../errors/errors' import { RuntimeSourceError } from '../errors/runtimeSourceError' import { TimeoutError } from '../errors/timeoutErrors' import { isPotentialInfiniteLoop } from '../infiniteLoops/errors' import { testForInfiniteLoop } from '../infiniteLoops/runtime' -import { evaluateProgram as evaluate } from '../interpreter/interpreter' import preprocessFileImports from '../modules/preprocessor' import { defaultAnalysisOptions } from '../modules/preprocessor/analyzer' import { defaultLinkerOptions } from '../modules/preprocessor/linker' import { parse } from '../parser/parser' -import { AsyncScheduler, PreemptiveScheduler } from '../schedulers' import { callee, getEvaluationSteps, @@ -25,18 +23,16 @@ import { } from '../stepper/stepper' import { sandboxedEval } from '../transpiler/evalContainer' import { transpile } from '../transpiler/transpiler' -import { Chapter, type Context, type RecursivePartial, type Scheduler, Variant } from '../types' +import { Chapter, type Context, type RecursivePartial, Variant } from '../types' import { validateAndAnnotate } from '../validator/validator' -import { compileForConcurrent } from '../vm/svml-compiler' -import { runWithProgram } from '../vm/svml-machine' import type { FileGetter } from '../modules/moduleTypes' import { mapResult } from '../alt-langs/mapper' +import assert from '../utils/assert' import { toSourceError } from './errors' import { fullJSRunner } from './fullJSRunner' import { determineExecutionMethod, determineVariant, resolvedErrorPromise } from './utils' -const DEFAULT_SOURCE_OPTIONS: Readonly = { - scheduler: 'async', +export const DEFAULT_SOURCE_OPTIONS: Readonly = { steps: 1000, stepLimit: -1, executionMethod: 'auto', @@ -60,29 +56,6 @@ let previousCode: { } | null = null let isPreviousCodeTimeoutError = false -function runConcurrent(program: es.Program, context: Context, options: IOptions): Promise { - if (context.shouldIncreaseEvaluationTimeout) { - context.nativeStorage.maxExecTime *= JSSLANG_PROPERTIES.factorToIncreaseBy - } else { - context.nativeStorage.maxExecTime = options.originalMaxExecTime - } - - try { - return Promise.resolve({ - status: 'finished', - context, - value: runWithProgram(compileForConcurrent(program, context), context) - }) - } catch (error) { - if (error instanceof RuntimeSourceError || error instanceof ExceptionError) { - context.errors.push(error) // use ExceptionErrors for non Source Errors - return resolvedErrorPromise - } - context.errors.push(new ExceptionError(error, UNKNOWN_LOCATION)) - return resolvedErrorPromise - } -} - function runSubstitution( program: es.Program, context: Context, @@ -110,17 +83,6 @@ function runSubstitution( }) } -function runInterpreter(program: es.Program, context: Context, options: IOptions): Promise { - let it = evaluate(program, context) - let scheduler: Scheduler - if (options.scheduler === 'async') { - scheduler = new AsyncScheduler() - } else { - scheduler = new PreemptiveScheduler(options.steps) - } - return scheduler.run(it, context) -} - async function runNative( program: es.Program, context: Context, @@ -226,10 +188,6 @@ async function sourceRunner( return resolvedErrorPromise } - if (context.variant === Variant.CONCURRENT) { - return runConcurrent(program, context, theOptions) - } - if (theOptions.useSubst) { return runSubstitution(program, context, theOptions) } @@ -238,7 +196,7 @@ async function sourceRunner( // native, don't evaluate prelude if (context.executionMethod === 'native' && context.variant === Variant.NATIVE) { - return await fullJSRunner(program, context, theOptions.importOptions) + return fullJSRunner(program, context, theOptions.importOptions) } // All runners after this point evaluate the prelude. @@ -264,11 +222,11 @@ async function sourceRunner( return runCSEMachine(program, context, theOptions) } - if (context.executionMethod === 'native') { - return runNative(program, context, theOptions) - } - - return runInterpreter(program, context, theOptions) + assert( + context.executionMethod !== 'auto', + 'Execution method should have been properly determined!' + ) + return runNative(program, context, theOptions) } /** diff --git a/src/schedulers.ts b/src/schedulers.ts deleted file mode 100644 index 94a521f7c..000000000 --- a/src/schedulers.ts +++ /dev/null @@ -1,105 +0,0 @@ -/* tslint:disable:max-classes-per-file */ -import { MaximumStackLimitExceeded } from './errors/errors' -import { saveState } from './stdlib/inspector' -import { Context, Result, Scheduler, Value } from './types' - -export class AsyncScheduler implements Scheduler { - public run(it: IterableIterator, context: Context): Promise { - return new Promise((resolve, _reject) => { - context.runtime.isRunning = true - let itValue = it.next() - try { - while (!itValue.done) { - itValue = it.next() - if (context.runtime.break) { - saveState(context, it, this) - itValue.done = true - } - } - } catch (e) { - resolve({ status: 'error' }) - } finally { - context.runtime.isRunning = false - } - if (context.runtime.break) { - resolve({ - status: 'suspended', - it, - scheduler: this, - context - }) - } else { - resolve({ status: 'finished', context, value: itValue.value }) - } - }) - } -} - -export class PreemptiveScheduler implements Scheduler { - constructor(public steps: number) {} - - public run(it: IterableIterator, context: Context): Promise { - return new Promise((resolve, _reject) => { - context.runtime.isRunning = true - // This is used in the evaluation of the REPL during a paused state. - // The debugger is turned off while the code evaluates just above the debugger statement. - let actuallyBreak: boolean = false - let itValue = it.next() - const interval = setInterval(() => { - let step = 0 - try { - while (!itValue.done && step < this.steps) { - step++ - itValue = it.next() - - actuallyBreak = context.runtime.break && context.runtime.debuggerOn - if (actuallyBreak) { - itValue.done = true - } - } - saveState(context, it, this) - } catch (e) { - checkForStackOverflow(e, context) - context.runtime.isRunning = false - clearInterval(interval) - resolve({ status: 'error' }) - } - if (itValue.done) { - context.runtime.isRunning = false - clearInterval(interval) - if (actuallyBreak) { - resolve({ - status: 'suspended', - it, - scheduler: this, - context - }) - } else { - resolve({ status: 'finished', context, value: itValue.value }) - } - } - }) - }) - } -} - -/* Checks if the error is a stackoverflow error, and captures it in the - context if this is the case */ -function checkForStackOverflow(error: any, context: Context) { - if (/Maximum call stack/.test(error.toString())) { - const environments = context.runtime.environments - const stacks: any = [] - let counter = 0 - for ( - let i = 0; - counter < MaximumStackLimitExceeded.MAX_CALLS_TO_SHOW && i < environments.length; - i++ - ) { - if (environments[i].callExpression) { - stacks.unshift(environments[i].callExpression) - counter++ - } - } - context.errors.push(new MaximumStackLimitExceeded(context.runtime.nodes[0], stacks)) - } -} diff --git a/src/stdlib/__tests__/__snapshots__/list.ts.snap b/src/stdlib/__tests__/__snapshots__/list.ts.snap deleted file mode 100644 index e0d1de59a..000000000 --- a/src/stdlib/__tests__/__snapshots__/list.ts.snap +++ /dev/null @@ -1,1098 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad index error list_ref: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "list_ref(list(1, 2, 3), 3);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 216: Error: head(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad index error list_ref: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "list_ref(list(1, 2, 3), -1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 217: Error: tail(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad index error list_ref: expectParsedError 3`] = ` -Object { - "alertResult": Array [], - "code": "list_ref(list(1, 2, 3), 1.5);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 217: Error: tail(xs) expects a pair as argument xs, but encountered null", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad index error list_ref: expectParsedError 4`] = ` -Object { - "alertResult": Array [], - "code": "list_ref(list(1, 2, 3), '1');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 215: Expected string on right hand side of operation, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad number error build_list: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "build_list(x => x, '1');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 63: Expected number on left hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad number error enum_list: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "enum_list('1', '5');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 203: Expected string on right hand side of operation, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad number error enum_list: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "enum_list('1', 5);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 201: Expected string on right hand side of operation, got number.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. bad number error enum_list: expectParsedError 3`] = ` -Object { - "alertResult": Array [], - "code": "enum_list(1, '5');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 201: Expected number on right hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error accumulate: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "accumulate((x, y) => x + y, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 3 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error accumulate: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "accumulate((x, y) => x + y, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Expected 3 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error append: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "append([1, 2, 3], list(1, 2, 3));", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 121: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error assoc: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "assoc(1, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Name assoc not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error filter: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "filter(x => true, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 185: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error for_each: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for_each(x=>x, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 76: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error length: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "length([1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 33: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error map: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "map(x=>x, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 47: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error member: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "member(1, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 136: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error remove: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "remove(1, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 151: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error remove_all: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "remove_all(1, [1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 169: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error reverse: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "reverse([1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 106: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error set_head: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "set_head([1, 2, 3], 4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: set_head(xs,x) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`These tests are reporting weird line numbers, as list functions are now implemented in Source. non-list error set_tail: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "set_tail([1, 2, 3], 4);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: set_tail(xs,x) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`accumulate works from right to left: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "accumulate((curr, acc) => curr + acc, '1', list('4','3','2'));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "4321", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`accumulate works properly: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "accumulate((curr, acc) => curr + acc, 0, list(2, 3, 4, 1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`accumulate: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "accumulate((curr, acc) => curr + acc, 0, list(2, 3, 4, 1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 10, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`append: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(append(list(123, 123), list(456, 456, 456)), list(123, 123, 456, 456, 456));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`build_list: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(build_list(x => x * x, 5), list(0, 1, 4, 9, 16));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list MCE fuzz test: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(parse('const twice = f => x => {const result = f(f(x)); return two;};')); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(\\"constant_declaration\\", - list(\\"name\\", \\"twice\\"), - list(\\"lambda_expression\\", - list(list(\\"name\\", \\"f\\")), - list(\\"return_statement\\", - list(\\"lambda_expression\\", - list(list(\\"name\\", \\"x\\")), - list(\\"block\\", - list(\\"sequence\\", - list(list(\\"constant_declaration\\", - list(\\"name\\", \\"result\\"), - list(\\"application\\", - list(\\"name\\", \\"f\\"), - list(list(\\"application\\", list(\\"name\\", \\"f\\"), list(list(\\"name\\", \\"x\\")))))), - list(\\"return_statement\\", list(\\"name\\", \\"two\\")))))))))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list checks prepend type: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => i, 5), true); -0; // suppress long result in snapshot", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: TypeError: display_list expects the second argument to be a string", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`display_list infinite list 2: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const p = list(1, 2, 3); -set_tail(tail(tail(p)), p); -display_list(p); -0; // suppress long result in snapshot", - "displayResult": Array [ - "[1, [2, [3, ...]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list infinite list of list of infinite list: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const build_inf = (i, f) => { - const t = list(f(i)); - let p = t; - for (let n = i - 1; n >= 0; n = n - 1) { - p = pair(f(n), p); - } - set_tail(t, p); - return p; -}; -display_list(build_inf(3, i => build_list(i => build_inf(i, i=>i), i))); -0; // suppress long result in snapshot", - "displayResult": Array [ - "[ null, -[ list([0, ...]), -[ list([0, ...], [0, [1, ...]]), -[ list([0, ...], [0, [1, ...]], [0, [1, [2, ...]]]), -...]]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list infinite list: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const p = list(1); -set_tail(p, p); -display_list(p); -0; // suppress long result in snapshot", - "displayResult": Array [ - "[1, ...]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list list of infinite list of list: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const build_inf = (i, f) => { - const t = list(f(i)); - let p = t; - for (let n = i - 1; n >= 0; n = n - 1) { - p = pair(f(n), p); - } - set_tail(t, p); - return p; -}; -display_list(build_list(i => build_inf(i, i => build_list(i => i, i)), 3)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list([null, ...], - [null, [list(0), ...]], - [null, [list(0), [list(0, 1), ...]]])", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list list of infinite list: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const build_inf = i => { - const t = list(i); - let p = t; - for (let n = i - 1; n >= 0; n = n - 1) { - p = pair(n, p); - } - set_tail(t, p); - return p; -}; -display_list(build_list(build_inf, 5)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list([0, ...], - [0, [1, ...]], - [0, [1, [2, ...]]], - [0, [1, [2, [3, ...]]]], - [0, [1, [2, [3, [4, ...]]]]])", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list returns argument: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = build_list(i => i, 5); -xs === display_list(xs); -// Note reference equality", - "displayResult": Array [ - "list(0, 1, 2, 3, 4)", - ], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list returns cyclic argument: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const build_inf = (i, f) => { - const t = list(f(i)); - let p = t; - for (let n = i - 1; n >= 0; n = n - 1) { - p = pair(f(n), p); - } - set_tail(t, p); - return p; -}; -const xs = build_inf(5, i=>i); -xs === display_list(xs); -// Note reference equality", - "displayResult": Array [ - "[0, [1, [2, [3, [4, [5, ...]]]]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list reusing lists 2: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const p1 = pair(1, null); -const p2 = pair(2, p1); -const p3 = list(p1, p2); -display_list(p3); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(list(1), list(2, 1))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list reusing lists: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const p = list(1); -const p2 = pair(p, p); -const p3 = list(p, p2); -display_list(p3); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(list(1), list(list(1), 1))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list standard acyclic 2: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => build_list(j => j, i), 5)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(null, list(0), list(0, 1), list(0, 1, 2), list(0, 1, 2, 3))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list standard acyclic multiline: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => build_list(j => j, i), 20)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(null, - list(0), - list(0, 1), - list(0, 1, 2), - list(0, 1, 2, 3), - list(0, 1, 2, 3, 4), - list(0, 1, 2, 3, 4, 5), - list(0, 1, 2, 3, 4, 5, 6), - list(0, 1, 2, 3, 4, 5, 6, 7), - list(0, 1, 2, 3, 4, 5, 6, 7, 8), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list standard acyclic with pairs 2: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => build_list(j => pair(build_list(k => k, j), j), i), 5)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(null, - list([null, 0]), - list([null, 0], [list(0), 1]), - list([null, 0], [list(0), 1], [list(0, 1), 2]), - list([null, 0], [list(0), 1], [list(0, 1), 2], [list(0, 1, 2), 3]))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list standard acyclic with pairs: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => build_list(j => pair(j, j), i), 5)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(null, - list([0, 0]), - list([0, 0], [1, 1]), - list([0, 0], [1, 1], [2, 2]), - list([0, 0], [1, 1], [2, 2], [3, 3]))", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list standard acyclic: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => i, 5)); -0; // suppress long result in snapshot", - "displayResult": Array [ - "list(0, 1, 2, 3, 4)", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`display_list supports prepend string: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(build_list(i => i, 5), \\"build_list:\\"); -0; // suppress long result in snapshot", - "displayResult": Array [ - "build_list: list(0, 1, 2, 3, 4)", - ], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`empty list is null: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`enum_list with floats: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(enum_list(1.5, 5), list(1.5, 2.5, 3.5, 4.5));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`enum_list: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(enum_list(1, 5), list(1, 2, 3, 4, 5));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`equal: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "!equal(1, x => x) && !equal(x => x, 1);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`filter: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(filter(x => x <= 4, list(2, 10, 1000, 1, 3, 100, 4, 5, 2, 1000)), list(2, 1, 3, 4, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for_each: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let sum = 0; -for_each(x => { - sum = sum + x; -}, list(1, 2, 3)); -sum;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 6, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`head works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "head(pair(1, 'a string \\"\\"'));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`length works with empty lists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = list(); -length(xs);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`length works with populated lists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const xs = list(1,2,3,4); -length(xs);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 4, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`list creates list: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { return 1; } -list(1, 'a string \\"\\"', () => f, f, true, 3.14);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - "a string \\"\\"", - Array [ - [Function], - Array [ - [Function], - Array [ - true, - Array [ - 3.14, - null, - ], - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`list_ref: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list_ref(list(1, 2, 3, \\"4\\", 4), 4);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 4, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`list_to_string: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "list_to_string(list(1, 2, 3));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "[1,[2,[3,null]]]", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`map: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(map(x => 2 * x, list(12, 11, 3)), list(24, 22, 6));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`member: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal( - member(4, list(1, 2, 3, 4, 123, 456, 789)), - list(4, 123, 456, 789));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`non-list error head: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "head([1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`non-list error tail: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "tail([1, 2, 3]);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`pair creates pair: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "pair(1, 'a string \\"\\"');", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - "a string \\"\\"", - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove not found: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "remove(2, list(1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - null, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "remove(1, list(1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove_all not found: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(remove_all(1, list(2, 3, 4)), list(2, 3, 4));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove_all: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(remove_all(1, list(1, 2, 3, 4, 1, 1, 1, 5, 1, 1, 6)), list(2, 3, 4, 5, 6));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`reverse: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(reverse(list(\\"string\\", \\"null\\", \\"undefined\\", \\"null\\", 123)), list(123, \\"null\\", \\"undefined\\", \\"null\\", \\"string\\"));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`set_head: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let p = pair(1, 2); -const q = p; -set_head(p, 3); -p === q && equal(p, pair(3, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`set_tail: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let p = pair(1, 2); -const q = p; -set_tail(p, 3); -p === q && equal(p, pair(1, 3));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`tail of a 1 element list is null: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(list(1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`tail works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "tail(pair(1, 'a string \\"\\"'));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "a string \\"\\"", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/__snapshots__/localImport.ts.snap b/src/stdlib/__tests__/__snapshots__/localImport.ts.snap deleted file mode 100644 index aa22047ce..000000000 --- a/src/stdlib/__tests__/__snapshots__/localImport.ts.snap +++ /dev/null @@ -1,116 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`__access_export__ returns default export if it exists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - return pair(cube, list(pair(\\"square\\", square))); -} -// When 'null' is passed in as the name of the export, -// '__access_export__' returns the default export. -const square = __access_export__(importedFile(), \\"default\\"); -square(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 125, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`__access_export__ returns named export if it exists: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - return pair(1 + 2, list(pair(\\"square\\", square), pair(\\"cube\\", cube))); -} -const square = __access_export__(importedFile(), \\"square\\"); -square(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 25, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`__access_named_export__ returns first identifier if name exists multiple times in list of exported names: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - // The second instance of the name 'square' actually refers to the function 'cube'. - return list(pair(\\"square\\", square), pair(\\"square\\", cube), pair(\\"cube\\", cube)); -} -const square = __access_named_export__(importedFile(), \\"square\\"); -square(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 25, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`__access_named_export__ returns identifier if name exists in list of exported names: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - return list(pair(\\"square\\", square), pair(\\"cube\\", cube)); -} -const square = __access_named_export__(importedFile(), \\"square\\"); -square(5);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 25, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`__access_named_export__ returns undefined if list of exported names is empty: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - return list(); -} -__access_named_export__(importedFile(), \\"identity\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`__access_named_export__ returns undefined if name does not exist in list of exported names: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function importedFile() { - const square = x => x * x; - const cube = x => x * x * x; - return list(pair(\\"square\\", square), pair(\\"cube\\", cube)); -} -__access_named_export__(importedFile(), \\"identity\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/__snapshots__/misc.ts.snap b/src/stdlib/__tests__/__snapshots__/misc.ts.snap deleted file mode 100644 index 0e93053b8..000000000 --- a/src/stdlib/__tests__/__snapshots__/misc.ts.snap +++ /dev/null @@ -1,280 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`arity ignores the rest parameter: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(display);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with function with parameters is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(arity);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with non-function arg f throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "arity('function');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: arity expects a function as argument", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`arity with nullary function is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(math_random);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with user-made function is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(x, y) { - return x + y; -} -arity(test);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with user-made function with rest parameter is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function test(...xs) { - return xs; -} -arity(test);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with user-made lambda function is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(x => x);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`arity with user-made nullary function is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(() => undefined);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`char_at with non nonnegative integer second argument errors: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "char_at('', -1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: char_at expects the second argument to be a nonnegative integer.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`char_at with non nonnegative integer second argument errors: expectParsedError 2`] = ` -Object { - "alertResult": Array [], - "code": "char_at('', \\"\\");", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: char_at expects the second argument to be a nonnegative integer.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`char_at with non string first argument errors: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "char_at(42, 123);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: char_at expects the first argument to be a string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`char_at with valid args (but index out of bounds) returns undefined: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "char_at(\\"123\\", 3);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": undefined, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`char_at with valid args is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "char_at(\\"123\\", 0);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "1", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with non-integer arg radix throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(42, 2.1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: parse_int expects two arguments a string s, and a positive integer i between 2 and 36, inclusive.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with non-string arg str throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(42, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: parse_int expects two arguments a string s, and a positive integer i between 2 and 36, inclusive.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with radix outside [2, 36] throws error, radix=1: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: parse_int expects two arguments a string s, and a positive integer i between 2 and 36, inclusive.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with radix outside [2, 36] throws error, radix=37: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('10', 37);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: parse_int expects two arguments a string s, and a positive integer i between 2 and 36, inclusive.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with string arg radix throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int(42, '2');", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: parse_int expects two arguments a string s, and a positive integer i between 2 and 36, inclusive.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with valid args is ok, but invalid str for radix: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('uu1', 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": NaN, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with valid args is ok, radix 2: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('1100101010101', 2);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 6485, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`parse_int with valid args is ok, radix 36: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "parse_int('uu1', 36);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 39961, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/__snapshots__/parser-errors.ts.snap b/src/stdlib/__tests__/__snapshots__/parser-errors.ts.snap deleted file mode 100644 index 4e0dc6769..000000000 --- a/src/stdlib/__tests__/__snapshots__/parser-errors.ts.snap +++ /dev/null @@ -1,27 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Blacklisted syntax: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse(\\"function* f() { yield 1; } f();\\"), undefined, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: ParseError: Yield expressions are not allowed", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`Blatant syntax error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "stringify(parse(\\"'\\"), undefined, 2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: ParseError: SyntaxError: Unterminated string constant (1:0)", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/__snapshots__/parser.ts.snap b/src/stdlib/__tests__/__snapshots__/parser.ts.snap new file mode 100644 index 000000000..779bee969 --- /dev/null +++ b/src/stdlib/__tests__/__snapshots__/parser.ts.snap @@ -0,0 +1,131804 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Parses arrow function assignments properly 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 56, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const y = x => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "const y = x => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 42, + "line": 1, + }, + }, + "name": "undefined", + "start": 42, + "type": "Identifier", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 53, + "line": 1, + }, + }, + "raw": "2", + "start": 53, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const y = x => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 56, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 39, + "loc": SourceLocation { + "end": Position { + "column": 39, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const y = x => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "const y = x => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 42, + "line": 1, + }, + }, + "name": "undefined", + "start": 42, + "type": "Identifier", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 53, + "line": 1, + }, + }, + "raw": "2", + "start": 53, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const y = x => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"constant_declaration\\", +[ [ \\"name\\", + [ \\"y\\", + null]], +[ [ \\"lambda_expression\\", + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + [ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]], + null]]], +null]]]", + }, +} +`; + +exports[`Parses arrow function expressions properly 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 46, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "x => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 32, + "line": 1, + }, + }, + "name": "undefined", + "start": 32, + "type": "Identifier", + }, + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 43, + "line": 1, + }, + }, + "raw": "2", + "start": 43, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 46, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "x => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 32, + "line": 1, + }, + }, + "name": "undefined", + "start": 32, + "type": "Identifier", + }, + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 43, + "line": 1, + }, + }, + "raw": "2", + "start": 43, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"lambda_expression\\", +[ [ [ \\"name\\", + [ \\"x\\", + null]], + null], +[ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]], +null]]]", + }, +} +`; + +exports[`Parses assignment expressions 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 45, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x = y = x;\\"", + "start": 16, + "type": "Literal", + "value": "x = y = x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 31, + "line": 1, + }, + }, + "name": "undefined", + "start": 31, + "type": "Identifier", + }, + Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 42, + "line": 1, + }, + }, + "raw": "2", + "start": 42, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x = y = x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 45, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 28, + "loc": SourceLocation { + "end": Position { + "column": 28, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x = y = x;\\"", + "start": 16, + "type": "Literal", + "value": "x = y = x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 29, + "loc": SourceLocation { + "end": Position { + "column": 29, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 40, + "loc": SourceLocation { + "end": Position { + "column": 40, + "line": 1, + }, + "start": Position { + "column": 31, + "line": 1, + }, + }, + "name": "undefined", + "start": 31, + "type": "Identifier", + }, + Node { + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 42, + "line": 1, + }, + }, + "raw": "2", + "start": 42, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x = y = x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"assignment\\", +[ [ \\"name\\", + [ \\"x\\", + null]], +[ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"y\\", + null]], + [ [ \\"name\\", + [ \\"x\\", + null]], + null]]], +null]]]", + }, +} +`; + +exports[`Parses assignment statements 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 77, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x = 5; x = x; if (true) { x = 5; } else {}\\"", + "start": 16, + "type": "Literal", + "value": "x = 5; x = x; if (true) { x = 5; } else {}", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 63, + "line": 1, + }, + }, + "name": "undefined", + "start": 63, + "type": "Identifier", + }, + Node { + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 75, + "line": 1, + }, + "start": Position { + "column": 74, + "line": 1, + }, + }, + "raw": "2", + "start": 74, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 76, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 77, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 77, + "loc": SourceLocation { + "end": Position { + "column": 77, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x = 5; x = x; if (true) { x = 5; } else {}\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 77, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x = 5; x = x; if (true) { x = 5; } else {}\\"", + "start": 16, + "type": "Literal", + "value": "x = 5; x = x; if (true) { x = 5; } else {}", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 63, + "line": 1, + }, + }, + "name": "undefined", + "start": 63, + "type": "Identifier", + }, + Node { + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 75, + "line": 1, + }, + "start": Position { + "column": 74, + "line": 1, + }, + }, + "raw": "2", + "start": 74, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 76, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 77, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 77, + "loc": SourceLocation { + "end": Position { + "column": 77, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x = 5; x = x; if (true) { x = 5; } else {}\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"x\\", + null]], + null]]], + [ [ \\"conditional_statement\\", + [ [ \\"literal\\", + [ true, + null]], + [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"sequence\\", + [ null, + null]], + null]]]], + null]]], +null]]", + }, +} +`; + +exports[`Parses declaration statements 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 58, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const x = 5; let y = x;\\"", + "start": 16, + "type": "Literal", + "value": "const x = 5; let y = x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 44, + "line": 1, + }, + }, + "name": "undefined", + "start": 44, + "type": "Identifier", + }, + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 55, + "line": 1, + }, + }, + "raw": "2", + "start": 55, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const x = 5; let y = x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 58, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 41, + "loc": SourceLocation { + "end": Position { + "column": 41, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const x = 5; let y = x;\\"", + "start": 16, + "type": "Literal", + "value": "const x = 5; let y = x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 44, + "line": 1, + }, + }, + "name": "undefined", + "start": 44, + "type": "Identifier", + }, + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 55, + "line": 1, + }, + }, + "raw": "2", + "start": 55, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const x = 5; let y = x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"constant_declaration\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"variable_declaration\\", + [ [ \\"name\\", + [ \\"y\\", + null]], + [ [ \\"name\\", + [ \\"x\\", + null]], + null]]], + null]], +null]]", + }, +} +`; + +exports[`Parses default export declarations 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 74, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"export const x = 42; export default x;\\"", + "start": 17, + "type": "Literal", + "value": "export const x = 42; export default x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 60, + "line": 1, + }, + }, + "name": "undefined", + "start": 60, + "type": "Identifier", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 71, + "line": 1, + }, + }, + "raw": "2", + "start": 71, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + Node { + "end": 162, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 92, + "line": 1, + }, + }, + "raw": "\\"export default function square(x) { return x * x; }\\"", + "start": 92, + "type": "Literal", + "value": "export default function square(x) { return x * x; }", + }, + ], + "callee": Node { + "end": 90, + "loc": SourceLocation { + "end": Position { + "column": 90, + "line": 1, + }, + "start": Position { + "column": 85, + "line": 1, + }, + }, + "name": "parse", + "start": 85, + "type": "Identifier", + }, + "end": 146, + "loc": SourceLocation { + "end": Position { + "column": 146, + "line": 1, + }, + "start": Position { + "column": 85, + "line": 1, + }, + }, + "start": 85, + "type": "CallExpression", + }, + Node { + "end": 157, + "loc": SourceLocation { + "end": Position { + "column": 157, + "line": 1, + }, + "start": Position { + "column": 148, + "line": 1, + }, + }, + "name": "undefined", + "start": 148, + "type": "Identifier", + }, + Node { + "end": 160, + "loc": SourceLocation { + "end": Position { + "column": 160, + "line": 1, + }, + "start": Position { + "column": 159, + "line": 1, + }, + }, + "raw": "2", + "start": 159, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "name": "stringify", + "start": 75, + "type": "Identifier", + }, + "end": 161, + "loc": SourceLocation { + "end": Position { + "column": 161, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "start": 75, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 162, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "start": 75, + "type": "ExpressionStatement", + }, + ], + "end": 162, + "loc": SourceLocation { + "end": Position { + "column": 162, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"export const x = 42; export default x;\\"), undefined, 2); stringify(parse( \\"export default function square(x) { return x * x; }\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 74, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"export const x = 42; export default x;\\"", + "start": 17, + "type": "Literal", + "value": "export const x = 42; export default x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 60, + "line": 1, + }, + }, + "name": "undefined", + "start": 60, + "type": "Identifier", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 71, + "line": 1, + }, + }, + "raw": "2", + "start": 71, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + Node { + "end": 162, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 92, + "line": 1, + }, + }, + "raw": "\\"export default function square(x) { return x * x; }\\"", + "start": 92, + "type": "Literal", + "value": "export default function square(x) { return x * x; }", + }, + ], + "callee": Node { + "end": 90, + "loc": SourceLocation { + "end": Position { + "column": 90, + "line": 1, + }, + "start": Position { + "column": 85, + "line": 1, + }, + }, + "name": "parse", + "start": 85, + "type": "Identifier", + }, + "end": 146, + "loc": SourceLocation { + "end": Position { + "column": 146, + "line": 1, + }, + "start": Position { + "column": 85, + "line": 1, + }, + }, + "start": 85, + "type": "CallExpression", + }, + Node { + "end": 157, + "loc": SourceLocation { + "end": Position { + "column": 157, + "line": 1, + }, + "start": Position { + "column": 148, + "line": 1, + }, + }, + "name": "undefined", + "start": 148, + "type": "Identifier", + }, + Node { + "end": 160, + "loc": SourceLocation { + "end": Position { + "column": 160, + "line": 1, + }, + "start": Position { + "column": 159, + "line": 1, + }, + }, + "raw": "2", + "start": 159, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "name": "stringify", + "start": 75, + "type": "Identifier", + }, + "end": 161, + "loc": SourceLocation { + "end": Position { + "column": 161, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "start": 75, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 162, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "start": 75, + "type": "ExpressionStatement", + }, + ], + "end": 162, + "loc": SourceLocation { + "end": Position { + "column": 162, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"export const x = 42; export default x;\\"), undefined, 2); stringify(parse( \\"export default function square(x) { return x * x; }\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"export_default_declaration\\", +[ [ \\"function_declaration\\", + [ [ \\"name\\", + [ \\"square\\", + null]], + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + [ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"*\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"x\\", + null]], + null]]]], + null]], + null]]]], +null]]", + }, +} +`; + +exports[`Parses default import specifiers 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 76, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"import defaultExport from 'module-name';\\"", + "start": 17, + "type": "Literal", + "value": "import defaultExport from 'module-name';", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 71, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 62, + "line": 1, + }, + }, + "name": "undefined", + "start": 62, + "type": "Identifier", + }, + Node { + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 73, + "line": 1, + }, + }, + "raw": "2", + "start": 73, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 75, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 76, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"import defaultExport from 'module-name';\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 76, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"import defaultExport from 'module-name';\\"", + "start": 17, + "type": "Literal", + "value": "import defaultExport from 'module-name';", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 71, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 62, + "line": 1, + }, + }, + "name": "undefined", + "start": 62, + "type": "Identifier", + }, + Node { + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 73, + "line": 1, + }, + }, + "raw": "2", + "start": 73, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 75, + "loc": SourceLocation { + "end": Position { + "column": 75, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 76, + "loc": SourceLocation { + "end": Position { + "column": 76, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"import defaultExport from 'module-name';\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"import_declaration\\", +[ [ [ \\"default\\", + null], + null], +[ \\"module-name\\", +null]]]", + }, +} +`; + +exports[`Parses empty program 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 35, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"\\"", + "start": 16, + "type": "Literal", + "value": "", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "name": "undefined", + "start": 21, + "type": "Identifier", + }, + Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 32, + "line": 1, + }, + }, + "raw": "2", + "start": 32, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 35, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 18, + "loc": SourceLocation { + "end": Position { + "column": 18, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"\\"", + "start": 16, + "type": "Literal", + "value": "", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 19, + "loc": SourceLocation { + "end": Position { + "column": 19, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 30, + "loc": SourceLocation { + "end": Position { + "column": 30, + "line": 1, + }, + "start": Position { + "column": 21, + "line": 1, + }, + }, + "name": "undefined", + "start": 21, + "type": "Identifier", + }, + Node { + "end": 33, + "loc": SourceLocation { + "end": Position { + "column": 33, + "line": 1, + }, + "start": Position { + "column": 32, + "line": 1, + }, + }, + "raw": "2", + "start": 32, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ null, +null]]", + }, +} +`; + +exports[`Parses fibonacci 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 103, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 86, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);\\"", + "start": 16, + "type": "Literal", + "value": "function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 87, + "loc": SourceLocation { + "end": Position { + "column": 87, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 98, + "loc": SourceLocation { + "end": Position { + "column": 98, + "line": 1, + }, + "start": Position { + "column": 89, + "line": 1, + }, + }, + "name": "undefined", + "start": 89, + "type": "Identifier", + }, + Node { + "end": 101, + "loc": SourceLocation { + "end": Position { + "column": 101, + "line": 1, + }, + "start": Position { + "column": 100, + "line": 1, + }, + }, + "raw": "2", + "start": 100, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 102, + "loc": SourceLocation { + "end": Position { + "column": 102, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 103, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 103, + "loc": SourceLocation { + "end": Position { + "column": 103, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 103, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 86, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);\\"", + "start": 16, + "type": "Literal", + "value": "function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 87, + "loc": SourceLocation { + "end": Position { + "column": 87, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 98, + "loc": SourceLocation { + "end": Position { + "column": 98, + "line": 1, + }, + "start": Position { + "column": 89, + "line": 1, + }, + }, + "name": "undefined", + "start": 89, + "type": "Identifier", + }, + Node { + "end": 101, + "loc": SourceLocation { + "end": Position { + "column": 101, + "line": 1, + }, + "start": Position { + "column": 100, + "line": 1, + }, + }, + "raw": "2", + "start": 100, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 102, + "loc": SourceLocation { + "end": Position { + "column": 102, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 103, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 103, + "loc": SourceLocation { + "end": Position { + "column": 103, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"function_declaration\\", + [ [ \\"name\\", + [ \\"fib\\", + null]], + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + [ [ \\"return_statement\\", + [ [ \\"conditional_expression\\", + [ [ \\"binary_operator_combination\\", + [ \\"<=\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"application\\", + [ [ \\"name\\", + [ \\"fib\\", + null]], + [ [ [ \\"binary_operator_combination\\", + [ \\"-\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null], + null]]], + [ [ \\"application\\", + [ [ \\"name\\", + [ \\"fib\\", + null]], + [ [ [ \\"binary_operator_combination\\", + [ \\"-\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 2, + null]], + null]]]], + null], + null]]], + null]]]], + null]]]], + null]], + null]]]], + [ [ \\"application\\", + [ [ \\"name\\", + [ \\"fib\\", + null]], + [ [ [ \\"literal\\", + [ 4, + null]], + null], + null]]], + null]], +null]]", + }, +} +`; + +exports[`Parses function calls 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 69, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 52, + "loc": SourceLocation { + "end": Position { + "column": 52, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"f(x); thrice(thrice)(plus_one)(0);\\"", + "start": 16, + "type": "Literal", + "value": "f(x); thrice(thrice)(plus_one)(0);", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 55, + "line": 1, + }, + }, + "name": "undefined", + "start": 55, + "type": "Identifier", + }, + Node { + "end": 67, + "loc": SourceLocation { + "end": Position { + "column": 67, + "line": 1, + }, + "start": Position { + "column": 66, + "line": 1, + }, + }, + "raw": "2", + "start": 66, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 68, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"f(x); thrice(thrice)(plus_one)(0);\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 69, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 52, + "loc": SourceLocation { + "end": Position { + "column": 52, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"f(x); thrice(thrice)(plus_one)(0);\\"", + "start": 16, + "type": "Literal", + "value": "f(x); thrice(thrice)(plus_one)(0);", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 53, + "loc": SourceLocation { + "end": Position { + "column": 53, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 55, + "line": 1, + }, + }, + "name": "undefined", + "start": 55, + "type": "Identifier", + }, + Node { + "end": 67, + "loc": SourceLocation { + "end": Position { + "column": 67, + "line": 1, + }, + "start": Position { + "column": 66, + "line": 1, + }, + }, + "raw": "2", + "start": 66, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 68, + "loc": SourceLocation { + "end": Position { + "column": 68, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"f(x); thrice(thrice)(plus_one)(0);\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"application\\", + [ [ \\"name\\", + [ \\"f\\", + null]], + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + null]]], + [ [ \\"application\\", + [ [ \\"application\\", + [ [ \\"application\\", + [ [ \\"name\\", + [ \\"thrice\\", + null]], + [ [ [ \\"name\\", + [ \\"thrice\\", + null]], + null], + null]]], + [ [ [ \\"name\\", + [ \\"plus_one\\", + null]], + null], + null]]], + [ [ [ \\"literal\\", + [ 0, + null]], + null], + null]]], + null]], +null]]", + }, +} +`; + +exports[`Parses if statements 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 89, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"if (true) { hi; } else { haha; } if (false) {} else {}\\"", + "start": 16, + "type": "Literal", + "value": "if (true) { hi; } else { haha; } if (false) {} else {}", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "name": "undefined", + "start": 75, + "type": "Identifier", + }, + Node { + "end": 87, + "loc": SourceLocation { + "end": Position { + "column": 87, + "line": 1, + }, + "start": Position { + "column": 86, + "line": 1, + }, + }, + "raw": "2", + "start": 86, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 88, + "loc": SourceLocation { + "end": Position { + "column": 88, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 89, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 89, + "loc": SourceLocation { + "end": Position { + "column": 89, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"if (true) { hi; } else { haha; } if (false) {} else {}\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 89, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"if (true) { hi; } else { haha; } if (false) {} else {}\\"", + "start": 16, + "type": "Literal", + "value": "if (true) { hi; } else { haha; } if (false) {} else {}", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 75, + "line": 1, + }, + }, + "name": "undefined", + "start": 75, + "type": "Identifier", + }, + Node { + "end": 87, + "loc": SourceLocation { + "end": Position { + "column": 87, + "line": 1, + }, + "start": Position { + "column": 86, + "line": 1, + }, + }, + "raw": "2", + "start": 86, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 88, + "loc": SourceLocation { + "end": Position { + "column": 88, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 89, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 89, + "loc": SourceLocation { + "end": Position { + "column": 89, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"if (true) { hi; } else { haha; } if (false) {} else {}\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"conditional_statement\\", + [ [ \\"literal\\", + [ true, + null]], + [ [ \\"name\\", + [ \\"hi\\", + null]], + [ [ \\"name\\", + [ \\"haha\\", + null]], + null]]]], + [ [ \\"conditional_statement\\", + [ [ \\"literal\\", + [ false, + null]], + [ [ \\"sequence\\", + [ null, + null]], + [ [ \\"sequence\\", + [ null, + null]], + null]]]], + null]], +null]]", + }, +} +`; + +exports[`Parses infix expressions 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 65, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"3 + 5 === 8 || !true && false;\\"", + "start": 16, + "type": "Literal", + "value": "3 + 5 === 8 || !true && false;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 51, + "line": 1, + }, + }, + "name": "undefined", + "start": 51, + "type": "Identifier", + }, + Node { + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 62, + "line": 1, + }, + }, + "raw": "2", + "start": 62, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 65, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"3 + 5 === 8 || !true && false;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 65, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 48, + "loc": SourceLocation { + "end": Position { + "column": 48, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"3 + 5 === 8 || !true && false;\\"", + "start": 16, + "type": "Literal", + "value": "3 + 5 === 8 || !true && false;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 51, + "line": 1, + }, + }, + "name": "undefined", + "start": 51, + "type": "Identifier", + }, + Node { + "end": 63, + "loc": SourceLocation { + "end": Position { + "column": 63, + "line": 1, + }, + "start": Position { + "column": 62, + "line": 1, + }, + }, + "raw": "2", + "start": 62, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 64, + "loc": SourceLocation { + "end": Position { + "column": 64, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 65, + "loc": SourceLocation { + "end": Position { + "column": 65, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"3 + 5 === 8 || !true && false;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"logical_composition\\", +[ \\"||\\", +[ [ \\"binary_operator_combination\\", + [ \\"===\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"literal\\", + [ 3, + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]]], + [ [ \\"literal\\", + [ 8, + null]], + null]]]], +[ [ \\"logical_composition\\", + [ \\"&&\\", + [ [ \\"unary_operator_combination\\", + [ \\"!\\", + [ [ \\"literal\\", + [ true, + null]], + null]]], + [ [ \\"literal\\", + [ false, + null]], + null]]]], +null]]]]", + }, +} +`; + +exports[`Parses literals 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 74, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"3; true; false; ''; \\\\\\"\\\\\\"; 'bob'; 1; 20;\\"", + "start": 16, + "type": "Literal", + "value": "3; true; false; ''; \\"\\"; 'bob'; 1; 20;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 60, + "line": 1, + }, + }, + "name": "undefined", + "start": 60, + "type": "Identifier", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 71, + "line": 1, + }, + }, + "raw": "2", + "start": 71, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"3; true; false; ''; \\\\\\"\\\\\\"; 'bob'; 1; 20;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 74, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"3; true; false; ''; \\\\\\"\\\\\\"; 'bob'; 1; 20;\\"", + "start": 16, + "type": "Literal", + "value": "3; true; false; ''; \\"\\"; 'bob'; 1; 20;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 60, + "line": 1, + }, + }, + "name": "undefined", + "start": 60, + "type": "Identifier", + }, + Node { + "end": 72, + "loc": SourceLocation { + "end": Position { + "column": 72, + "line": 1, + }, + "start": Position { + "column": 71, + "line": 1, + }, + }, + "raw": "2", + "start": 71, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 73, + "loc": SourceLocation { + "end": Position { + "column": 73, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 74, + "loc": SourceLocation { + "end": Position { + "column": 74, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"3; true; false; ''; \\\\\\"\\\\\\"; 'bob'; 1; 20;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"literal\\", + [ 3, + null]], + [ [ \\"literal\\", + [ true, + null]], + [ [ \\"literal\\", + [ false, + null]], + [ [ \\"literal\\", + [ \\"\\", + null]], + [ [ \\"literal\\", + [ \\"\\", + null]], + [ [ \\"literal\\", + [ \\"bob\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + [ [ \\"literal\\", + [ 20, + null]], + null]]]]]]]], +null]]", + }, +} +`; + +exports[`Parses loops 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 175, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 158, + "loc": SourceLocation { + "end": Position { + "column": 158, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }\\"", + "start": 17, + "type": "Literal", + "value": "while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 159, + "loc": SourceLocation { + "end": Position { + "column": 159, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 170, + "loc": SourceLocation { + "end": Position { + "column": 170, + "line": 1, + }, + "start": Position { + "column": 161, + "line": 1, + }, + }, + "name": "undefined", + "start": 161, + "type": "Identifier", + }, + Node { + "end": 173, + "loc": SourceLocation { + "end": Position { + "column": 173, + "line": 1, + }, + "start": Position { + "column": 172, + "line": 1, + }, + }, + "raw": "2", + "start": 172, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 174, + "loc": SourceLocation { + "end": Position { + "column": 174, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 175, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 175, + "loc": SourceLocation { + "end": Position { + "column": 175, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 175, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 158, + "loc": SourceLocation { + "end": Position { + "column": 158, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }\\"", + "start": 17, + "type": "Literal", + "value": "while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 159, + "loc": SourceLocation { + "end": Position { + "column": 159, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 170, + "loc": SourceLocation { + "end": Position { + "column": 170, + "line": 1, + }, + "start": Position { + "column": 161, + "line": 1, + }, + }, + "name": "undefined", + "start": 161, + "type": "Identifier", + }, + Node { + "end": 173, + "loc": SourceLocation { + "end": Position { + "column": 173, + "line": 1, + }, + "start": Position { + "column": 172, + "line": 1, + }, + }, + "raw": "2", + "start": 172, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 174, + "loc": SourceLocation { + "end": Position { + "column": 174, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 175, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 175, + "loc": SourceLocation { + "end": Position { + "column": 175, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"while (true) { continue; break; } for (let i = 0; i < 1; i = i + 1) { continue; break; } for (i = 0; i < 1; i = i + 1) { continue; break; }\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"while_loop\\", + [ [ \\"literal\\", + [ true, + null]], + [ [ \\"sequence\\", + [ [ [ \\"continue_statement\\", + null], + [ [ \\"break_statement\\", + null], + null]], + null]], + null]]], + [ [ \\"for_loop\\", + [ [ \\"variable_declaration\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 0, + null]], + null]]], + [ [ \\"binary_operator_combination\\", + [ \\"<\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]]], + [ [ \\"sequence\\", + [ [ [ \\"continue_statement\\", + null], + [ [ \\"break_statement\\", + null], + null]], + null]], + null]]]]], + [ [ \\"for_loop\\", + [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 0, + null]], + null]]], + [ [ \\"binary_operator_combination\\", + [ \\"<\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + [ [ \\"assignment\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"i\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]]], + [ [ \\"sequence\\", + [ [ [ \\"continue_statement\\", + null], + [ [ \\"break_statement\\", + null], + null]], + null]], + null]]]]], + null]]], +null]]", + }, +} +`; + +exports[`Parses multi-argument arrow function assignments properly 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 61, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const y = (x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "const y = (x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 47, + "line": 1, + }, + }, + "name": "undefined", + "start": 47, + "type": "Identifier", + }, + Node { + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 58, + "line": 1, + }, + }, + "raw": "2", + "start": 58, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const y = (x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 61, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 44, + "loc": SourceLocation { + "end": Position { + "column": 44, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"const y = (x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "const y = (x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 45, + "loc": SourceLocation { + "end": Position { + "column": 45, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 56, + "loc": SourceLocation { + "end": Position { + "column": 56, + "line": 1, + }, + "start": Position { + "column": 47, + "line": 1, + }, + }, + "name": "undefined", + "start": 47, + "type": "Identifier", + }, + Node { + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 58, + "line": 1, + }, + }, + "raw": "2", + "start": 58, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 60, + "loc": SourceLocation { + "end": Position { + "column": 60, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 61, + "loc": SourceLocation { + "end": Position { + "column": 61, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"const y = (x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"constant_declaration\\", +[ [ \\"name\\", + [ \\"y\\", + null]], +[ [ \\"lambda_expression\\", + [ [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"y\\", + null]], + null]], + [ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]], + null]]], +null]]]", + }, +} +`; + +exports[`Parses multi-argument arrow function expressions properly 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"(x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "(x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 37, + "line": 1, + }, + }, + "name": "undefined", + "start": 37, + "type": "Identifier", + }, + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 48, + "line": 1, + }, + }, + "raw": "2", + "start": 48, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"(x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"(x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "(x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 37, + "line": 1, + }, + }, + "name": "undefined", + "start": 37, + "type": "Identifier", + }, + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 48, + "line": 1, + }, + }, + "raw": "2", + "start": 48, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"(x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"lambda_expression\\", +[ [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"y\\", + null]], + null]], +[ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]], +null]]]", + }, +} +`; + +exports[`Parses multi-argument arrow function expressions properly 2`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"(x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "(x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 37, + "line": 1, + }, + }, + "name": "undefined", + "start": 37, + "type": "Identifier", + }, + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 48, + "line": 1, + }, + }, + "raw": "2", + "start": 48, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": true, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"(x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 51, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 34, + "loc": SourceLocation { + "end": Position { + "column": 34, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"(x, y) => x + 1;\\"", + "start": 16, + "type": "Literal", + "value": "(x, y) => x + 1;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 46, + "loc": SourceLocation { + "end": Position { + "column": 46, + "line": 1, + }, + "start": Position { + "column": 37, + "line": 1, + }, + }, + "name": "undefined", + "start": 37, + "type": "Identifier", + }, + Node { + "end": 49, + "loc": SourceLocation { + "end": Position { + "column": 49, + "line": 1, + }, + "start": Position { + "column": 48, + "line": 1, + }, + }, + "raw": "2", + "start": 48, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 50, + "loc": SourceLocation { + "end": Position { + "column": 50, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 51, + "loc": SourceLocation { + "end": Position { + "column": 51, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": true, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"(x, y) => x + 1;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"lambda_expression\\", +[ [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"y\\", + null]], + null]], +[ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"+\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 1, + null]], + null]]]], + null]], +null]]]", + }, +} +`; + +exports[`Parses name expression 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 37, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x;\\"", + "start": 16, + "type": "Literal", + "value": "x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 23, + "line": 1, + }, + }, + "name": "undefined", + "start": 23, + "type": "Identifier", + }, + Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 34, + "line": 1, + }, + }, + "raw": "2", + "start": 34, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 37, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 20, + "loc": SourceLocation { + "end": Position { + "column": 20, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x;\\"", + "start": 16, + "type": "Literal", + "value": "x;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 21, + "loc": SourceLocation { + "end": Position { + "column": 21, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 32, + "loc": SourceLocation { + "end": Position { + "column": 32, + "line": 1, + }, + "start": Position { + "column": 23, + "line": 1, + }, + }, + "name": "undefined", + "start": 23, + "type": "Identifier", + }, + Node { + "end": 35, + "loc": SourceLocation { + "end": Position { + "column": 35, + "line": 1, + }, + "start": Position { + "column": 34, + "line": 1, + }, + }, + "raw": "2", + "start": 34, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 36, + "loc": SourceLocation { + "end": Position { + "column": 36, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 37, + "loc": SourceLocation { + "end": Position { + "column": 37, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"name\\", +[ \\"x\\", +null]]", + }, +} +`; + +exports[`Parses name expressions 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 59, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x; moreNames; undefined;\\"", + "start": 16, + "type": "Literal", + "value": "x; moreNames; undefined;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 45, + "line": 1, + }, + }, + "name": "undefined", + "start": 45, + "type": "Identifier", + }, + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 56, + "line": 1, + }, + }, + "raw": "2", + "start": 56, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x; moreNames; undefined;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 4, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 59, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"x; moreNames; undefined;\\"", + "start": 16, + "type": "Literal", + "value": "x; moreNames; undefined;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 45, + "line": 1, + }, + }, + "name": "undefined", + "start": 45, + "type": "Identifier", + }, + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 56, + "line": 1, + }, + }, + "raw": "2", + "start": 56, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "head": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"x; moreNames; undefined;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"moreNames\\", + null]], + [ [ \\"name\\", + [ \\"undefined\\", + null]], + null]]], +null]]", + }, +} +`; + +exports[`Parses named export declarations 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 145, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 128, + "loc": SourceLocation { + "end": Position { + "column": 128, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };\\"", + "start": 17, + "type": "Literal", + "value": "export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 129, + "loc": SourceLocation { + "end": Position { + "column": 129, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 140, + "loc": SourceLocation { + "end": Position { + "column": 140, + "line": 1, + }, + "start": Position { + "column": 131, + "line": 1, + }, + }, + "name": "undefined", + "start": 131, + "type": "Identifier", + }, + Node { + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 143, + "line": 1, + }, + "start": Position { + "column": 142, + "line": 1, + }, + }, + "raw": "2", + "start": 142, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 144, + "loc": SourceLocation { + "end": Position { + "column": 144, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 145, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 128, + "loc": SourceLocation { + "end": Position { + "column": 128, + "line": 1, + }, + "start": Position { + "column": 17, + "line": 1, + }, + }, + "raw": "\\"export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };\\"", + "start": 17, + "type": "Literal", + "value": "export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 129, + "loc": SourceLocation { + "end": Position { + "column": 129, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 140, + "loc": SourceLocation { + "end": Position { + "column": 140, + "line": 1, + }, + "start": Position { + "column": 131, + "line": 1, + }, + }, + "name": "undefined", + "start": 131, + "type": "Identifier", + }, + Node { + "end": 143, + "loc": SourceLocation { + "end": Position { + "column": 143, + "line": 1, + }, + "start": Position { + "column": 142, + "line": 1, + }, + }, + "raw": "2", + "start": 142, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 144, + "loc": SourceLocation { + "end": Position { + "column": 144, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 145, + "loc": SourceLocation { + "end": Position { + "column": 145, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse( \\"export const x = 42; export const square = x => x * x; export function id(x) { return x; } export { x as y };\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"export_named_declaration\\", + [ [ \\"constant_declaration\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"literal\\", + [ 42, + null]], + null]]], + null]], + [ [ \\"export_named_declaration\\", + [ [ \\"constant_declaration\\", + [ [ \\"name\\", + [ \\"square\\", + null]], + [ [ \\"lambda_expression\\", + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + [ [ \\"return_statement\\", + [ [ \\"binary_operator_combination\\", + [ \\"*\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + [ [ \\"name\\", + [ \\"x\\", + null]], + null]]]], + null]], + null]]], + null]]], + null]], + [ [ \\"export_named_declaration\\", + [ [ \\"function_declaration\\", + [ [ \\"name\\", + [ \\"id\\", + null]], + [ [ [ \\"name\\", + [ \\"x\\", + null]], + null], + [ [ \\"return_statement\\", + [ [ \\"name\\", + [ \\"x\\", + null]], + null]], + null]]]], + null]], + [ [ \\"export_named_declaration\\", + [ [ [ \\"name\\", + [ \\"y\\", + null]]], + null]], + null]]]], +null]]", + }, +} +`; + +exports[`Parses object notation 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 71, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 5, b: 10, 'key': value};\\"", + "start": 16, + "type": "Literal", + "value": "let x = {a: 5, b: 10, 'key': value};", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 66, + "loc": SourceLocation { + "end": Position { + "column": 66, + "line": 1, + }, + "start": Position { + "column": 57, + "line": 1, + }, + }, + "name": "undefined", + "start": 57, + "type": "Identifier", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 68, + "line": 1, + }, + }, + "raw": "2", + "start": 68, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 70, + "loc": SourceLocation { + "end": Position { + "column": 70, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 71, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"let x = {a: 5, b: 10, 'key': value};\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 71, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"let x = {a: 5, b: 10, 'key': value};\\"", + "start": 16, + "type": "Literal", + "value": "let x = {a: 5, b: 10, 'key': value};", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 55, + "loc": SourceLocation { + "end": Position { + "column": 55, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 66, + "loc": SourceLocation { + "end": Position { + "column": 66, + "line": 1, + }, + "start": Position { + "column": 57, + "line": 1, + }, + }, + "name": "undefined", + "start": 57, + "type": "Identifier", + }, + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 68, + "line": 1, + }, + }, + "raw": "2", + "start": 68, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 70, + "loc": SourceLocation { + "end": Position { + "column": 70, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 71, + "loc": SourceLocation { + "end": Position { + "column": 71, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"let x = {a: 5, b: 10, 'key': value};\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"variable_declaration\\", +[ [ \\"name\\", + [ \\"x\\", + null]], +[ [ \\"object_expression\\", + [ [ [ \\"key_value_pair\\", + [ [ \\"property\\", + [ \\"a\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"key_value_pair\\", + [ [ \\"property\\", + [ \\"b\\", + null]], + [ [ \\"literal\\", + [ 10, + null]], + null]]], + [ [ \\"key_value_pair\\", + [ [ \\"literal\\", + [ \\"key\\", + null]], + [ [ \\"name\\", + [ \\"value\\", + null]], + null]]], + null]]], + null]], +null]]]", + }, +} +`; + +exports[`Parses property access 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 59, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"a[b]; a.b; a[5]; a['b'];\\"", + "start": 16, + "type": "Literal", + "value": "a[b]; a.b; a[5]; a['b'];", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 45, + "line": 1, + }, + }, + "name": "undefined", + "start": 45, + "type": "Identifier", + }, + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 56, + "line": 1, + }, + }, + "raw": "2", + "start": 56, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"a[b]; a.b; a[5]; a['b'];\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 59, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 42, + "loc": SourceLocation { + "end": Position { + "column": 42, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"a[b]; a.b; a[5]; a['b'];\\"", + "start": 16, + "type": "Literal", + "value": "a[b]; a.b; a[5]; a['b'];", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 43, + "loc": SourceLocation { + "end": Position { + "column": 43, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 54, + "loc": SourceLocation { + "end": Position { + "column": 54, + "line": 1, + }, + "start": Position { + "column": 45, + "line": 1, + }, + }, + "name": "undefined", + "start": 45, + "type": "Identifier", + }, + Node { + "end": 57, + "loc": SourceLocation { + "end": Position { + "column": 57, + "line": 1, + }, + "start": Position { + "column": 56, + "line": 1, + }, + }, + "raw": "2", + "start": 56, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 58, + "loc": SourceLocation { + "end": Position { + "column": 58, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 59, + "loc": SourceLocation { + "end": Position { + "column": 59, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"a[b]; a.b; a[5]; a['b'];\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"name\\", + [ \\"b\\", + null]], + null]]], + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"property\\", + [ \\"b\\", + null]], + null]]], + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"literal\\", + [ \\"b\\", + null]], + null]]], + null]]]], +null]]", + }, +} +`; + +exports[`Parses property assignment 1`] = ` +Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 86, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;\\"", + "start": 16, + "type": "Literal", + "value": "a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 70, + "loc": SourceLocation { + "end": Position { + "column": 70, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 81, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 72, + "line": 1, + }, + }, + "name": "undefined", + "start": 72, + "type": "Identifier", + }, + Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 83, + "line": 1, + }, + }, + "raw": "2", + "start": 83, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 85, + "loc": SourceLocation { + "end": Position { + "column": 85, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 86, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "result": Object { + "context": Object { + "alertResult": Array [], + "chapter": 100, + "debugger": Object { + "observers": Object { + "callbacks": Array [], + }, + "state": Object { + "it": Object {}, + }, + "status": false, + }, + "displayResult": Array [], + "errors": Array [], + "executionMethod": "native", + "externalContext": undefined, + "externalSymbols": Array [], + "moduleContexts": Object {}, + "nativeStorage": Object { + "builtins": Map { + "get_time" => [Function], + "display" => [Function], + "raw_display" => [Function], + "stringify" => [Function], + "error" => [Function], + "prompt" => [Function], + "is_number" => [Function], + "is_string" => [Function], + "is_function" => [Function], + "is_boolean" => [Function], + "is_undefined" => [Function], + "parse_int" => [Function], + "char_at" => [Function], + "arity" => [Function], + "undefined" => undefined, + "NaN" => NaN, + "Infinity" => Infinity, + "math_abs" => [Function], + "math_acos" => [Function], + "math_acosh" => [Function], + "math_asin" => [Function], + "math_asinh" => [Function], + "math_atan" => [Function], + "math_atanh" => [Function], + "math_atan2" => [Function], + "math_ceil" => [Function], + "math_cbrt" => [Function], + "math_expm1" => [Function], + "math_clz32" => [Function], + "math_cos" => [Function], + "math_cosh" => [Function], + "math_exp" => [Function], + "math_floor" => [Function], + "math_fround" => [Function], + "math_hypot" => [Function], + "math_imul" => [Function], + "math_log" => [Function], + "math_log1p" => [Function], + "math_log2" => [Function], + "math_log10" => [Function], + "math_max" => [Function], + "math_min" => [Function], + "math_pow" => [Function], + "math_random" => [Function], + "math_round" => [Function], + "math_sign" => [Function], + "math_sin" => [Function], + "math_sinh" => [Function], + "math_sqrt" => [Function], + "math_tan" => [Function], + "math_tanh" => [Function], + "math_trunc" => [Function], + "math_E" => 2.718281828459045, + "math_LN10" => 2.302585092994046, + "math_LN2" => 0.6931471805599453, + "math_LOG10E" => 0.4342944819032518, + "math_LOG2E" => 1.4426950408889634, + "math_PI" => 3.141592653589793, + "math_SQRT1_2" => 0.7071067811865476, + "math_SQRT2" => 1.4142135623730951, + "pair" => [Function], + "is_pair" => [Function], + "head" => [Function], + "tail" => [Function], + "is_null" => [Function], + "list" => [Function], + "draw_data" => [Function], + "display_list" => [Function], + "is_list" => [Function], + "set_head" => [Function], + "set_tail" => [Function], + "array_length" => [Function], + "is_array" => [Function], + "stream" => [Function], + "parse" => [Function], + "tokenize" => [Function], + "apply_in_underlying_javascript" => [Function], + "call_cc" => [Function], + "is_object" => [Function], + "is_NaN" => [Function], + "has_own_property" => [Function], + "alert" => [Function], + "timed" => [Function], + }, + "evaller": [Function], + "loadedModuleTypes": Object {}, + "loadedModules": Object {}, + "maxExecTime": 1000, + "operators": Map { + "throwIfTimeout" => [Function], + "callIfFuncAndRightArgs" => [Function], + "boolOrErr" => [Function], + "unaryOp" => [Function], + "evaluateUnaryExpression" => [Function], + "binaryOp" => [Function], + "evaluateBinaryExpression" => [Function], + "callIteratively" => [Function], + "wrap" => [Function], + "setProp" => [Function], + "getProp" => [Function], + }, + "previousProgramsIdentifiers": Set { + "equal", + "$length", + "length", + "$map", + "map", + "$build_list", + "build_list", + "for_each", + "$list_to_string", + "list_to_string", + "$reverse", + "reverse", + "$append", + "append", + "member", + "$remove", + "remove", + "$remove_all", + "remove_all", + "$filter", + "filter", + "$enum_list", + "enum_list", + "list_ref", + "$accumulate", + "accumulate", + "__access_named_export__", + "__access_export__", + "stream_tail", + "is_stream", + "list_to_stream", + "stream_to_list", + "stream_length", + "stream_map", + "build_stream", + "stream_for_each", + "stream_reverse", + "stream_append", + "stream_member", + "stream_remove", + "stream_remove_all", + "stream_filter", + "enum_stream", + "integers_from", + "eval_stream", + "stream_ref", + }, + }, + "numberOfOuterEnvironments": 1, + "prelude": null, + "previousPrograms": Array [ + Object { + "body": Array [ + Node { + "end": 86, + "expression": Node { + "arguments": Array [ + Node { + "arguments": Array [ + Node { + "end": 69, + "loc": SourceLocation { + "end": Position { + "column": 69, + "line": 1, + }, + "start": Position { + "column": 16, + "line": 1, + }, + }, + "raw": "\\"a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;\\"", + "start": 16, + "type": "Literal", + "value": "a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;", + }, + ], + "callee": Node { + "end": 15, + "loc": SourceLocation { + "end": Position { + "column": 15, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "name": "parse", + "start": 10, + "type": "Identifier", + }, + "end": 70, + "loc": SourceLocation { + "end": Position { + "column": 70, + "line": 1, + }, + "start": Position { + "column": 10, + "line": 1, + }, + }, + "start": 10, + "type": "CallExpression", + }, + Node { + "end": 81, + "loc": SourceLocation { + "end": Position { + "column": 81, + "line": 1, + }, + "start": Position { + "column": 72, + "line": 1, + }, + }, + "name": "undefined", + "start": 72, + "type": "Identifier", + }, + Node { + "end": 84, + "loc": SourceLocation { + "end": Position { + "column": 84, + "line": 1, + }, + "start": Position { + "column": 83, + "line": 1, + }, + }, + "raw": "2", + "start": 83, + "type": "Literal", + "value": 2, + }, + ], + "callee": Node { + "end": 9, + "loc": SourceLocation { + "end": Position { + "column": 9, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "name": "stringify", + "start": 0, + "type": "Identifier", + }, + "end": 85, + "loc": SourceLocation { + "end": Position { + "column": 85, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "CallExpression", + }, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "start": 0, + "type": "ExpressionStatement", + }, + ], + "end": 86, + "loc": SourceLocation { + "end": Position { + "column": 86, + "line": 1, + }, + "start": Position { + "column": 0, + "line": 1, + }, + }, + "sourceType": "module", + "start": 0, + "type": "Program", + }, + ], + "promptResult": Array [], + "runtime": Object { + "break": false, + "breakpointSteps": Array [], + "changepointSteps": Array [], + "control": null, + "debuggerOn": true, + "envSteps": -1, + "envStepsTotal": 0, + "environmentTree": EnvTree { + "_root": EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + "map": Map { + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + } => EnvTreeNode { + "_children": Array [], + "environment": Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + "parent": null, + }, + }, + }, + "environments": Array [ + Object { + "head": Object { + "Infinity": Infinity, + "NaN": NaN, + "alert": [Function], + "apply_in_underlying_javascript": [Function], + "arity": [Function], + "array_length": [Function], + "call_cc": [Function], + "char_at": [Function], + "display": [Function], + "display_list": [Function], + "draw_data": [Function], + "error": [Function], + "get_time": [Function], + "has_own_property": [Function], + "head": [Function], + "is_NaN": [Function], + "is_array": [Function], + "is_boolean": [Function], + "is_function": [Function], + "is_list": [Function], + "is_null": [Function], + "is_number": [Function], + "is_object": [Function], + "is_pair": [Function], + "is_string": [Function], + "is_undefined": [Function], + "list": [Function], + "math_E": 2.718281828459045, + "math_LN10": 2.302585092994046, + "math_LN2": 0.6931471805599453, + "math_LOG10E": 0.4342944819032518, + "math_LOG2E": 1.4426950408889634, + "math_PI": 3.141592653589793, + "math_SQRT1_2": 0.7071067811865476, + "math_SQRT2": 1.4142135623730951, + "math_abs": [Function], + "math_acos": [Function], + "math_acosh": [Function], + "math_asin": [Function], + "math_asinh": [Function], + "math_atan": [Function], + "math_atan2": [Function], + "math_atanh": [Function], + "math_cbrt": [Function], + "math_ceil": [Function], + "math_clz32": [Function], + "math_cos": [Function], + "math_cosh": [Function], + "math_exp": [Function], + "math_expm1": [Function], + "math_floor": [Function], + "math_fround": [Function], + "math_hypot": [Function], + "math_imul": [Function], + "math_log": [Function], + "math_log10": [Function], + "math_log1p": [Function], + "math_log2": [Function], + "math_max": [Function], + "math_min": [Function], + "math_pow": [Function], + "math_random": [Function], + "math_round": [Function], + "math_sign": [Function], + "math_sin": [Function], + "math_sinh": [Function], + "math_sqrt": [Function], + "math_tan": [Function], + "math_tanh": [Function], + "math_trunc": [Function], + "pair": [Function], + "parse": [Function], + "parse_int": [Function], + "prompt": [Function], + "raw_display": [Function], + "set_head": [Function], + "set_tail": [Function], + "stream": [Function], + "stringify": [Function], + "tail": [Function], + "timed": [Function], + "tokenize": [Function], + "undefined": undefined, + }, + "heap": Heap { + "storage": null, + }, + "id": "-1", + "name": "global", + "tail": null, + }, + ], + "isRunning": false, + "nodes": Array [], + "objectCount": 0, + "stash": null, + "transformers": Transformers { + "items": Map {}, + "parent": null, + }, + "value": undefined, + }, + "shouldIncreaseEvaluationTimeout": false, + "typeEnvironment": Array [ + Object { + "declKindMap": Map { + "Infinity" => "const", + "NaN" => "const", + "undefined" => "const", + "math_E" => "const", + "math_LN2" => "const", + "math_LN10" => "const", + "math_LOG2E" => "const", + "math_LOG10E" => "const", + "math_PI" => "const", + "math_SQRT1_2" => "const", + "math_SQRT2" => "const", + "is_boolean" => "const", + "is_number" => "const", + "is_string" => "const", + "is_undefined" => "const", + "is_function" => "const", + "math_abs" => "const", + "math_acos" => "const", + "math_acosh" => "const", + "math_asin" => "const", + "math_asinh" => "const", + "math_atan" => "const", + "math_atan2" => "const", + "math_atanh" => "const", + "math_cbrt" => "const", + "math_ceil" => "const", + "math_clz32" => "const", + "math_cos" => "const", + "math_cosh" => "const", + "math_exp" => "const", + "math_expm1" => "const", + "math_floor" => "const", + "math_fround" => "const", + "math_hypot" => "const", + "math_imul" => "const", + "math_log" => "const", + "math_log1p" => "const", + "math_log2" => "const", + "math_log10" => "const", + "math_max" => "const", + "math_min" => "const", + "math_pow" => "const", + "math_random" => "const", + "math_round" => "const", + "math_sign" => "const", + "math_sin" => "const", + "math_sinh" => "const", + "math_sqrt" => "const", + "math_tan" => "const", + "math_tanh" => "const", + "math_trunc" => "const", + "parse_int" => "const", + "prompt" => "const", + "get_time" => "const", + "stringify" => "const", + "display" => "const", + "error" => "const", + "-_1" => "const", + "!" => "const", + "&&" => "const", + "||" => "const", + "<" => "const", + "<=" => "const", + ">" => "const", + ">=" => "const", + "+" => "const", + "%" => "const", + "-" => "const", + "*" => "const", + "/" => "const", + "pair" => "const", + "head" => "const", + "tail" => "const", + "is_pair" => "const", + "is_null" => "const", + "is_list" => "const", + "list" => "const", + "===" => "const", + "!==" => "const", + "set_head" => "const", + "set_tail" => "const", + "is_array" => "const", + "array_length" => "const", + "raw_display" => "const", + "char_at" => "const", + "arity" => "const", + "draw_data" => "const", + "display_list" => "const", + "stream" => "const", + "parse" => "const", + "tokenize" => "const", + "apply_in_underlying_javascript" => "const", + "call_cc" => "const", + "is_object" => "const", + "is_NaN" => "const", + "has_own_property" => "const", + "alert" => "const", + "timed" => "const", + }, + "typeAliasMap": Map { + "Pair" => Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + }, + "List" => Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + "Stream" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "Stream", + "typeArgs": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + }, + "typeParams": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + }, + }, + "typeMap": Map { + "Infinity" => Object { + "kind": "primitive", + "name": "number", + "value": Infinity, + }, + "NaN" => Object { + "kind": "primitive", + "name": "number", + "value": NaN, + }, + "undefined" => Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "math_E" => Object { + "kind": "primitive", + "name": "number", + "value": 2.718281828459045, + }, + "math_LN2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.6931471805599453, + }, + "math_LN10" => Object { + "kind": "primitive", + "name": "number", + "value": 2.302585092994046, + }, + "math_LOG2E" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4426950408889634, + }, + "math_LOG10E" => Object { + "kind": "primitive", + "name": "number", + "value": 0.4342944819032518, + }, + "math_PI" => Object { + "kind": "primitive", + "name": "number", + "value": 3.141592653589793, + }, + "math_SQRT1_2" => Object { + "kind": "primitive", + "name": "number", + "value": 0.7071067811865476, + }, + "math_SQRT2" => Object { + "kind": "primitive", + "name": "number", + "value": 1.4142135623730951, + }, + "is_boolean" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + "kind": "predicate", + }, + "is_number" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + "kind": "predicate", + }, + "is_string" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + "kind": "predicate", + }, + "is_undefined" => Object { + "ifTrueType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + "kind": "predicate", + }, + "is_function" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "U", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "math_abs" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_acosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_asinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atan2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_atanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cbrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_ceil" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_clz32" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cos" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_cosh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_exp" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_expm1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_floor" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_fround" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_hypot" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_imul" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log1p" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log2" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_log10" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_max" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_min" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "math_pow" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_random" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_round" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sign" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sin" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sinh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_sqrt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tan" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_tanh" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "math_trunc" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "parse_int" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "prompt" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "get_time" => Object { + "kind": "function", + "parameterTypes": Array [], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "stringify" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "string", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "error" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "-_1" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "!" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "&&" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "||" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "<" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "<=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + ">=" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "+" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + ], + "returnType": Object { + "constraint": "addable", + "kind": "variable", + "name": "A", + }, + }, + "typeParams": undefined, + }, + "%" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "-" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "*" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "/" => Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "pair" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + }, + "typeParams": undefined, + }, + "head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + ], + "returnType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "is_pair" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_null" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "is_list" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "list", + "typeAsPair": undefined, + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "===" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "!==" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "T2", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "boolean", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_head" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "set_tail" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "headType": Object { + "constraint": "none", + "kind": "variable", + "name": "headType", + "typeArgs": undefined, + }, + "kind": "pair", + "tailType": Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + }, + Object { + "constraint": "none", + "kind": "variable", + "name": "tailType", + "typeArgs": undefined, + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "undefined", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "is_array" => Object { + "ifTrueType": Object { + "kind": "forall", + "polyType": Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + "typeParams": undefined, + }, + "kind": "predicate", + }, + "array_length" => Object { + "kind": "forall", + "polyType": Object { + "kind": "function", + "parameterTypes": Array [ + Object { + "elementType": Object { + "constraint": "none", + "kind": "variable", + "name": "T", + "typeArgs": undefined, + }, + "kind": "array", + }, + ], + "returnType": Object { + "kind": "primitive", + "name": "number", + "value": undefined, + }, + }, + "typeParams": undefined, + }, + "raw_display" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "char_at" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "arity" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "draw_data" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "display_list" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "stream" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "parse" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "tokenize" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "apply_in_underlying_javascript" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "call_cc" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_object" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "is_NaN" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "has_own_property" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "alert" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + "timed" => Object { + "kind": "forall", + "polyType": Object { + "constraint": "none", + "kind": "variable", + "name": "T1", + "typeArgs": undefined, + }, + "typeParams": undefined, + }, + }, + }, + ], + "unTypecheckedCode": Array [ + "stringify(parse(\\"a[b] = 5; a.b = value; a[5] = 'value'; a['b'] = 42;\\"), undefined, 2);", + " + +// equal computes the structural equality +// over its arguments + +function equal(xs, ys) { + return is_pair(xs) + ? (is_pair(ys) && + equal(head(xs), head(ys)) && + equal(tail(xs), tail(ys))) + : is_null(xs) + ? is_null(ys) + : is_number(xs) + ? (is_number(ys) && xs === ys) + : is_boolean(xs) + ? (is_boolean(ys) && ((xs && ys) || (!xs && !ys))) + : is_string(xs) + ? (is_string(ys) && xs === ys) + : is_undefined(xs) + ? is_undefined(ys) + : is_function(xs) + // we know now that xs is a function, + // but we use an if check anyway to make use of the type predicate + ? (is_function(ys) && xs === ys) + : false; +} + + +// returns the length of a given argument list +// assumes that the argument is a list + +function $length(xs, acc) { + return is_null(xs) ? acc : $length(tail(xs), acc + 1); +} +function length(xs) { + return $length(xs, 0); +} + +// map applies first arg f, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// f is applied element-by-element: +// map(f, list(1, 2)) results in list(f(1), f(2)) + +function $map(f, xs, acc) { + return is_null(xs) + ? reverse(acc) + : $map(f, tail(xs), pair(f(head(xs)), acc)); +} +function map(f, xs) { + return $map(f, xs, null); +} + +// build_list takes a a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_list returns a list of n elements, that results from +// applying fun to the numbers from 0 to n-1. + +function $build_list(i, fun, already_built) { + return i < 0 ? already_built : $build_list(i - 1, fun, pair(fun(i), already_built)); +} + +function build_list(fun, n) { + return $build_list(n - 1, fun, null); +} + +// for_each applies first arg fun, assumed to be a unary function, +// to the elements of the second argument, assumed to be a list. +// fun is applied element-by-element: +// for_each(fun, list(1, 2)) results in the calls fun(1) and fun(2). +// for_each returns true. + +function for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return for_each(fun, tail(xs)); + } +} + +// list_to_string returns a string that represents the argument list. +// It applies itself recursively on the elements of the given list. +// When it encounters a non-list, it applies to_string to it. + +function $list_to_string(xs, cont) { + return is_null(xs) + ? cont(\\"null\\") + : is_pair(xs) + ? $list_to_string( + head(xs), + x => $list_to_string( + tail(xs), + y => cont(\\"[\\" + x + \\",\\" + y + \\"]\\"))) + : cont(stringify(xs)); +} + +function list_to_string(xs) { + return $list_to_string(xs, x => x); +} + +// reverse reverses the argument, assumed to be a list + +function $reverse(original, reversed) { + return is_null(original) + ? reversed + : $reverse(tail(original), pair(head(original), reversed)); +} + +function reverse(xs) { + return $reverse(xs, null); +} + +// append first argument, assumed to be a list, to the second argument. +// In the result null at the end of the first argument list +// is replaced by the second argument, regardless what the second +// argument consists of. + +function $append(xs, ys, cont) { + return is_null(xs) + ? cont(ys) + : $append(tail(xs), ys, zs => cont(pair(head(xs), zs))); +} + +function append(xs, ys) { + return $append(xs, ys, xs => xs); +} + +// member looks for a given first-argument element in the +// second argument, assumed to be a list. It returns the first +// postfix sublist that starts with the given element. It returns null if the +// element does not occur in the list + +function member(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? xs + : member(v, tail(xs)); +} + +// removes the first occurrence of a given first-argument element +// in second-argument, assmed to be a list. Returns the original +// list if there is no occurrence. + +function $remove(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? app(rev(acc), tail(xs)) + : $remove(v, tail(xs), pair(head(xs), acc)); +} + +function remove(v, xs) { + return $remove(v, xs, null); +} + +// Similar to remove, but removes all instances of v +// instead of just the first + +function $remove_all(v, xs, acc) { + // Ensure that typechecking of append and reverse are done independently + const app = append; + const rev = reverse; + return is_null(xs) + ? app(rev(acc), xs) + : v === head(xs) + ? $remove_all(v, tail(xs), acc) + : $remove_all(v, tail(xs), pair(head(xs), acc)); +} + +function remove_all(v, xs) { + return $remove_all(v, xs, null); +} + +// filter returns the sublist of elements of the second argument +// (assumed to be a list), for which the given predicate function +// returns true. + +function $filter(pred, xs, acc) { + return is_null(xs) + ? reverse(acc) + : pred(head(xs)) + ? $filter(pred, tail(xs), pair(head(xs), acc)) + : $filter(pred, tail(xs), acc); +} + +function filter(pred, xs) { + return $filter(pred, xs, null); +} + +// enumerates numbers starting from start, assumed to be a number, +// using a step size of 1, until the number exceeds end, assumed +// to be a number + +function $enum_list(start, end, acc) { + // Ensure that typechecking of reverse are done independently + const rev = reverse; + return start > end + ? rev(acc) + : $enum_list(start + 1, end, pair(start, acc)); +} + +function enum_list(start, end) { + return $enum_list(start, end, null); +} + +// Returns the item in xs (assumed to be a list) at index n, +// assumed to be a nonnegative integer. +// Note: the first item is at position 0 + +function list_ref(xs, n) { + return n === 0 + ? head(xs) + : list_ref(tail(xs), n - 1); +} + +// accumulate applies an operation op (assumed to be a binary function) +// to elements of sequence (assumed to be a list) in a right-to-left order. +// first apply op to the last element and initial, resulting in r1, then to +// the second-last element and r1, resulting in r2, etc, and finally +// to the first element and r_n-1, where n is the length of the +// list. +// accumulate(op, zero, list(1, 2, 3)) results in +// op(1, op(2, op(3, zero))) + +function $accumulate(f, initial, xs, cont) { + return is_null(xs) + ? cont(initial) + : $accumulate(f, initial, tail(xs), x => cont(f(head(xs), x))); +} + +function accumulate(f, initial, xs) { + return $accumulate(f, initial, xs, x => x); +} + +function __access_named_export__(named_exports, lookup_name) { + if (is_null(named_exports)) { + return undefined; + } else { + const name = head(head(named_exports)); + const identifier = tail(head(named_exports)); + if (name === lookup_name) { + return identifier; + } else { + return __access_named_export__(tail(named_exports), lookup_name); + } + } +} + +function __access_export__(exports, lookup_name) { + if (lookup_name === \\"default\\") { + return head(exports); + } else { + const named_exports = tail(exports); + return __access_named_export__(named_exports, lookup_name); + } +} + + +// Supporting streams in the Scheme style, following +// \\"stream discipline\\" + +// stream_tail returns the second component of the given pair +// throws an error if the argument is not a pair + +function stream_tail(xs) { + if (is_pair(xs)) { + const the_tail = tail(xs); + if (is_function(the_tail)) { + return the_tail(); + } else { + error(the_tail, + 'stream_tail(xs) expects a function as ' + + 'the tail of the argument pair xs, ' + + 'but encountered '); + } + } else { + error(xs, 'stream_tail(xs) expects a pair as ' + + 'argument xs, but encountered '); + } +} + +// is_stream recurses down the stream and checks that it ends with the +// empty list null + +function is_stream(xs) { + return is_null(xs) || + (is_pair(xs) && + is_function(tail(xs)) && + arity(tail(xs)) === 0 && + is_stream(stream_tail(xs))); +} + +// A stream is either null or a pair whose tail is +// a nullary function that returns a stream. + +function list_to_stream(xs) { + return is_null(xs) + ? null + : pair(head(xs), + () => list_to_stream(tail(xs))); +} + +// stream_to_list transforms a given stream to a list +// Lazy? No: stream_to_list needs to force the whole stream +function stream_to_list(xs) { + return is_null(xs) + ? null + : pair(head(xs), stream_to_list(stream_tail(xs))); +} + +// stream_length returns the length of a given argument stream +// throws an exception if the argument is not a stream +// Lazy? No: The function needs to explore the whole stream +function stream_length(xs) { + return is_null(xs) + ? 0 + : 1 + stream_length(stream_tail(xs)); +} + +// stream_map applies first arg f to the elements of the second +// argument, assumed to be a stream. +// f is applied element-by-element: +// stream_map(f,list_to_stream(list(1,2)) results in +// the same as list_to_stream(list(f(1),f(2))) +// stream_map throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? Yes: The argument stream is only explored as forced by +// the result stream. +function stream_map(f, s) { + return is_null(s) + ? null + : pair(f(head(s)), + () => stream_map(f, stream_tail(s))); +} + +// build_stream takes a function fun as first argument, +// and a nonnegative integer n as second argument, +// build_stream returns a stream of n elements, that results from +// applying fun to the numbers from 0 to n-1. +// Lazy? Yes: The result stream forces the applications of fun +// for the next element +function build_stream(fun, n) { + function build(i) { + return i >= n + ? null + : pair(fun(i), + () => build(i + 1)); + } + return build(0); +} + +// stream_for_each applies first arg fun to the elements of the stream +// passed as second argument. fun is applied element-by-element: +// for_each(fun,list_to_stream(list(1, 2,null))) results in the calls fun(1) +// and fun(2). +// stream_for_each returns true. +// stream_for_each throws an exception if the second argument is not a +// stream, and if the second argument is a nonempty stream and the +// first argument is not a function. +// Lazy? No: stream_for_each forces the exploration of the entire stream +function stream_for_each(fun, xs) { + if (is_null(xs)) { + return true; + } else { + fun(head(xs)); + return stream_for_each(fun, stream_tail(xs)); + } +} + +// stream_reverse reverses the argument stream +// stream_reverse throws an exception if the argument is not a stream. +// Lazy? No: stream_reverse forces the exploration of the entire stream +function stream_reverse(xs) { + function rev(original, reversed) { + return is_null(original) + ? reversed + : rev(stream_tail(original), + pair(head(original), () => reversed)); + } + return rev(xs, null); +} + +// stream_append appends first argument stream and second argument stream. +// In the result, null at the end of the first argument stream +// is replaced by the second argument stream +// stream_append throws an exception if the first argument is not a +// stream. +// Lazy? Yes: the result stream forces the actual append operation +function stream_append(xs, ys) { + return is_null(xs) + ? ys + : pair(head(xs), + () => stream_append(stream_tail(xs), ys)); +} + +// stream_member looks for a given first-argument element in a given +// second argument stream. It returns the first postfix substream +// that starts with the given element. It returns null if the +// element does not occur in the stream +// Lazy? Sort-of: stream_member forces the stream only until the element is found. +function stream_member(x, s) { + return is_null(s) + ? null + : head(s) === x + ? s + : stream_member(x, stream_tail(s)); +} + +// stream_remove removes the first occurrence of a given first-argument element +// in a given second-argument list. Returns the original list +// if there is no occurrence. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_tail(xs) + : pair(head(xs), + () => stream_remove(v, stream_tail(xs))); +} + +// stream_remove_all removes all instances of v instead of just the first. +// Lazy? Yes: the result stream forces the construction of each next element +function stream_remove_all(v, xs) { + return is_null(xs) + ? null + : v === head(xs) + ? stream_remove_all(v, stream_tail(xs)) + : pair(head(xs), () => stream_remove_all(v, stream_tail(xs))); +} + +// filter returns the substream of elements of given stream s +// for which the given predicate function p returns true. +// Lazy? Yes: The result stream forces the construction of +// each next element. Of course, the construction +// of the next element needs to go down the stream +// until an element is found for which p holds. +function stream_filter(p, s) { + return is_null(s) + ? null + : p(head(s)) + ? pair(head(s), + () => stream_filter(p, stream_tail(s))) + : stream_filter(p, stream_tail(s)); +} + +// enumerates numbers starting from start, +// using a step size of 1, until the number +// exceeds end. +// Lazy? Yes: The result stream forces the construction of +// each next element +function enum_stream(start, end) { + return start > end + ? null + : pair(start, + () => enum_stream(start + 1, end)); +} + +// integers_from constructs an infinite stream of integers +// starting at a given number n +// Lazy? Yes: The result stream forces the construction of +// each next element +function integers_from(n) { + return pair(n, + () => integers_from(n + 1)); +} + +// eval_stream constructs the list of the first n elements +// of a given stream s +// Lazy? Sort-of: eval_stream only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function eval_stream(s, n) { + function es(s, n) { + return n === 1 + ? list(head(s)) + : pair(head(s), + es(stream_tail(s), n - 1)); + } + return n === 0 + ? null + : es(s, n); +} + +// Returns the item in stream s at index n (the first item is at position 0) +// Lazy? Sort-of: stream_ref only forces the computation of +// the first n elements, and leaves the rest of +// the stream untouched. +function stream_ref(s, n) { + return n === 0 + ? head(s) + : stream_ref(stream_tail(s), n - 1); +} +", + ], + "variant": "default", + "visualiseListResult": Array [], + }, + "status": "finished", + "value": "[ \\"sequence\\", +[ [ [ \\"object_assignment\\", + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"name\\", + [ \\"b\\", + null]], + null]]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"object_assignment\\", + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"property\\", + [ \\"b\\", + null]], + null]]], + [ [ \\"name\\", + [ \\"value\\", + null]], + null]]], + [ [ \\"object_assignment\\", + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"literal\\", + [ 5, + null]], + null]]], + [ [ \\"literal\\", + [ \\"value\\", + null]], + null]]], + [ [ \\"object_assignment\\", + [ [ \\"object_access\\", + [ [ \\"name\\", + [ \\"a\\", + null]], + [ [ \\"literal\\", + [ \\"b\\", + null]], + null]]], + [ [ \\"literal\\", + [ 42, + null]], + null]]], + null]]]], +null]]", + }, +} +`; diff --git a/src/stdlib/__tests__/__snapshots__/pylib.ts.snap b/src/stdlib/__tests__/__snapshots__/pylib.ts.snap deleted file mode 100644 index ed7d150a6..000000000 --- a/src/stdlib/__tests__/__snapshots__/pylib.ts.snap +++ /dev/null @@ -1,352 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`adding a string and an integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"a\\" + 1", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "a1", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`adding an integer and a float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 + 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`adding two floats is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 + 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`adding two integers is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 + 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 3n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`cannot divide non-number values: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"a\\" / 2", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`cannot floor non-number values: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"a\\" // 2", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`cannot mod non-number values: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"a\\" % 2", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`cannot multiply non-number values: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "True * 2", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: Invalid types for multiply operation: boolean, bigint", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`cannot power non-number values: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "\\"a\\" ** 2", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 1: Error: Expected number on left hand side of operation, got string.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`dividing float and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 / 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0.5, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`dividing integer and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 / 1.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`dividing integer and integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 / 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0.5, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`flooring float and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 // 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`flooring integer and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 // 1.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`flooring integer and integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 // 1", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`minusing an integer from a float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 - 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": -1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`minusing two floats is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 - 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": -1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`minusing two integers is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 - 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": -1n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`modding float and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 % 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`modding integer and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 % 1.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`modding integer and integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 % 1", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 0n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`multiplying float and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 * 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`multiplying integer and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 * 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`multiplying integer and integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 * 2", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`powering float and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1.0 ** 2.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 1, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`powering integer and float is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 ** 1.0", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`powering integer and integer is ok: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "2 ** 1", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2n, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/__snapshots__/stream.ts.snap b/src/stdlib/__tests__/__snapshots__/stream.ts.snap deleted file mode 100644 index 4ab231de7..000000000 --- a/src/stdlib/__tests__/__snapshots__/stream.ts.snap +++ /dev/null @@ -1,303 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`append: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(stream_append(stream(\\"string\\", 123), stream(456, null, undefined))) - , list(\\"string\\", 123, 456, null, undefined));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`build_list: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(build_stream(x => x * x, 5)), list(0, 1, 4, 9, 16));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`enum_list with floats: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(enum_stream(1.5, 5)), list(1.5, 2.5, 3.5, 4.5));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`enum_list: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(enum_stream(1, 5)), list(1, 2, 3, 4, 5));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`filter: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal( - stream_to_list( - stream_filter(x => x <= 4, stream(2, 10, 1000, 1, 3, 100, 4, 5, 2, 1000)) - ) -, list(2, 1, 3, 4, 2));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`for_each: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let sum = 0; -stream_for_each(x => { - sum = sum + x; -}, stream(1, 2, 3)); -sum;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 6, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`list_ref: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_ref(stream(1, 2, 3, \\"4\\", 4), 4);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 4, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`map: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(stream_map(x => 2 * x, stream(12, 11, 3))), list(24, 22, 6));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`member: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal( - stream_to_list(stream_member(\\"string\\", stream(1, 2, 3, \\"string\\", 123, 456, null, undefined))), - list(\\"string\\", 123, 456, null, undefined));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions empty stream is null: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream();", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions stream is properly created: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const s = stream(true, false, undefined, 1, x=>x, null, -123, head); -const result = []; -stream_for_each(item => {result[array_length(result)] = item;}, s); -stream_ref(s,4)(22) === 22 && stream_ref(s,7)(pair('', '1')) === '1' && result;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": false, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions stream_tail is lazy: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_tail(integers_from(0));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - [Function], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions stream_tail works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "head(stream_tail(stream(1, 2)));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": 2, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions stream_to_list works for null: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_to_list(null);", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive stream functions stream_to_list works: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_to_list(stream(1, true, 3, 4.4, [1, 2]));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - Array [ - true, - Array [ - 3, - Array [ - 4.4, - Array [ - Array [ - 1, - 2, - ], - null, - ], - ], - ], - ], - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove not found: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_to_list(stream_remove(2, stream(1)));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": Array [ - 1, - null, - ], - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_remove(1, stream(1));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": null, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove_all not found: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(stream_remove_all(1, stream(2, 3, \\"1\\"))), list(2, 3, \\"1\\"));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`remove_all: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list(stream_remove_all(1, stream(1, 2, 3, 4, 1, 1, \\"1\\", 5, 1, 1, 6))), - list(2, 3, 4, \\"1\\", 5, 6));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`reverse: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "equal(stream_to_list( - stream_reverse( - stream(\\"string\\", null, undefined, null, 123))), -list(123, null, undefined, null, \\"string\\"));", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": true, - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; diff --git a/src/stdlib/__tests__/list-benchmark.ts b/src/stdlib/__tests__/list-benchmark.ts index 2190f4e55..78e3bd3cd 100644 --- a/src/stdlib/__tests__/list-benchmark.ts +++ b/src/stdlib/__tests__/list-benchmark.ts @@ -105,7 +105,6 @@ test('display_list is linear runtime', () => { `, { chapter: Chapter.SOURCE_3, - native: false, // we're measuring a builtin, no need for native testBuiltins: { no_display_list: noDisplayList } diff --git a/src/stdlib/__tests__/list.ts b/src/stdlib/__tests__/list.ts index e915b3678..81bf28f41 100644 --- a/src/stdlib/__tests__/list.ts +++ b/src/stdlib/__tests__/list.ts @@ -8,7 +8,7 @@ test('list creates list', () => { function f() { return 1; } list(1, 'a string ""', () => f, f, true, 3.14); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(` Array [ 1, @@ -37,7 +37,7 @@ test('pair creates pair', () => { stripIndent` pair(1, 'a string ""'); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(` Array [ 1, @@ -51,7 +51,7 @@ test('head works', () => { stripIndent` head(pair(1, 'a string ""')); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`1`) }) @@ -60,7 +60,7 @@ test('tail works', () => { stripIndent` tail(pair(1, 'a string ""')); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`"a string \\"\\""`) }) @@ -69,7 +69,7 @@ test('tail of a 1 element list is null', () => { stripIndent` tail(list(1)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`null`) }) @@ -78,7 +78,7 @@ test('empty list is null', () => { stripIndent` list(); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot('null') }) @@ -100,7 +100,7 @@ test('for_each', () => { }, list(1, 2, 3)); sum; `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`6`) }) @@ -109,7 +109,7 @@ test('map', () => { stripIndent` equal(map(x => 2 * x, list(12, 11, 3)), list(24, 22, 6)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -118,7 +118,7 @@ test('filter', () => { stripIndent` equal(filter(x => x <= 4, list(2, 10, 1000, 1, 3, 100, 4, 5, 2, 1000)), list(2, 1, 3, 4, 2)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -127,7 +127,7 @@ test('build_list', () => { stripIndent` equal(build_list(x => x * x, 5), list(0, 1, 4, 9, 16)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -136,7 +136,7 @@ test('reverse', () => { stripIndent` equal(reverse(list("string", "null", "undefined", "null", 123)), list(123, "null", "undefined", "null", "string")); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -145,7 +145,7 @@ test('append', () => { stripIndent` equal(append(list(123, 123), list(456, 456, 456)), list(123, 123, 456, 456, 456)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -156,7 +156,7 @@ test('member', () => { member(4, list(1, 2, 3, 4, 123, 456, 789)), list(4, 123, 456, 789)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -165,7 +165,7 @@ test('remove', () => { stripIndent` remove(1, list(1)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`null`) }) @@ -174,7 +174,7 @@ test('remove not found', () => { stripIndent` remove(2, list(1)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(` Array [ 1, @@ -188,7 +188,7 @@ test('remove_all', () => { stripIndent` equal(remove_all(1, list(1, 2, 3, 4, 1, 1, 1, 5, 1, 1, 6)), list(2, 3, 4, 5, 6)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -197,7 +197,7 @@ test('remove_all not found', () => { stripIndent` equal(remove_all(1, list(2, 3, 4)), list(2, 3, 4)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -206,7 +206,7 @@ test('enum_list', () => { stripIndent` equal(enum_list(1, 5), list(1, 2, 3, 4, 5)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -215,7 +215,7 @@ test('enum_list with floats', () => { stripIndent` equal(enum_list(1.5, 5), list(1.5, 2.5, 3.5, 4.5)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`true`) }) @@ -224,7 +224,7 @@ test('list_ref', () => { stripIndent` list_ref(list(1, 2, 3, "4", 4), 4); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`4`) }) @@ -233,7 +233,7 @@ test('accumulate', () => { stripIndent` accumulate((curr, acc) => curr + acc, 0, list(2, 3, 4, 1)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`10`) }) @@ -242,7 +242,7 @@ test('list_to_string', () => { stripIndent` list_to_string(list(1, 2, 3)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`"[1,[2,[3,null]]]"`) }) @@ -252,7 +252,7 @@ describe('accumulate', () => { stripIndent` accumulate((curr, acc) => curr + acc, 0, list(2, 3, 4, 1)); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`10`) }) @@ -260,7 +260,7 @@ describe('accumulate', () => { return expectResult( stripIndent` accumulate((curr, acc) => curr + acc, '1', list('4','3','2'));`, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot('"4321"') }) }) @@ -272,7 +272,7 @@ describe('length', () => { const xs = list(1,2,3,4); length(xs); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot('4') }) @@ -282,7 +282,7 @@ describe('length', () => { const xs = list(); length(xs); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot('0') }) }) @@ -293,7 +293,7 @@ test.skip('assoc', () => { stripIndent` equal(assoc(3, list(pair(1, 2), pair(3, 4))), pair(3, 4)); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`true`) }) @@ -302,7 +302,7 @@ test.skip('assoc not found', () => { stripIndent` equal(assoc(2, list(pair(1, 2), pair(3, 4))), false); `, - { chapter: Chapter.LIBRARY_PARSER, native: true } + { chapter: Chapter.LIBRARY_PARSER } ).toMatchInlineSnapshot(`true`) }) @@ -314,7 +314,7 @@ test('set_head', () => { set_head(p, 3); p === q && equal(p, pair(3, 2)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -326,7 +326,7 @@ test('set_tail', () => { set_tail(p, 3); p === q && equal(p, pair(1, 3)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -335,7 +335,7 @@ test('non-list error head', () => { stripIndent` head([1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 1: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -346,7 +346,7 @@ test('non-list error tail', () => { stripIndent` tail([1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 1: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -358,7 +358,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` length([1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 33: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -369,7 +369,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` map(x=>x, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 47: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -380,7 +380,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` for_each(x=>x, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 76: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -391,7 +391,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` reverse([1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 106: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -402,7 +402,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` append([1, 2, 3], list(1, 2, 3)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 121: Error: tail(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -413,7 +413,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` member(1, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 136: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -424,7 +424,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` remove(1, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 151: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -435,7 +435,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` remove_all(1, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 169: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -455,7 +455,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` filter(x => true, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 185: Error: head(xs) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -466,7 +466,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` accumulate((x, y) => x + y, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"Line 1: Expected 3 arguments, but got 2."`) }) @@ -475,7 +475,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` accumulate((x, y) => x + y, [1, 2, 3]); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`"Line 1: Expected 3 arguments, but got 2."`) }) @@ -484,7 +484,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` set_head([1, 2, 3], 4); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 1: Error: set_head(xs,x) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -495,7 +495,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` set_tail([1, 2, 3], 4); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot( `"Line 1: Error: set_tail(xs,x) expects a pair as argument xs, but encountered [1, 2, 3]"` ) @@ -507,7 +507,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` build_list(x => x, -1); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 1: Error: build_list(fun, n) expects a positive integer as argument n, but encountered -1"` ) @@ -519,7 +519,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` build_list(x => x, 1.5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 1: Error: build_list(fun, n) expects a positive integer as argument n, but encountered 1.5"` ) @@ -530,7 +530,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` build_list(x => x, '1'); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 63: Expected number on left hand side of operation, got string."` ) @@ -541,7 +541,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` enum_list('1', '5'); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 203: Expected string on right hand side of operation, got number."` ) @@ -552,7 +552,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` enum_list('1', 5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 201: Expected string on right hand side of operation, got number."` ) @@ -563,7 +563,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` enum_list(1, '5'); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 201: Expected number on right hand side of operation, got string."` ) @@ -574,7 +574,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` list_ref(list(1, 2, 3), 3); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 216: Error: head(xs) expects a pair as argument xs, but encountered null"` ) @@ -585,7 +585,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` list_ref(list(1, 2, 3), -1); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 217: Error: tail(xs) expects a pair as argument xs, but encountered null"` ) @@ -596,7 +596,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` list_ref(list(1, 2, 3), 1.5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 217: Error: tail(xs) expects a pair as argument xs, but encountered null"` ) @@ -607,7 +607,7 @@ describe('These tests are reporting weird line numbers, as list functions are no stripIndent` list_ref(list(1, 2, 3), '1'); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 215: Expected string on right hand side of operation, got number."` ) @@ -621,12 +621,8 @@ describe('display_list', () => { display_list(build_list(i => i, 5)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(0, 1, 2, 3, 4)", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('standard acyclic 2', () => { @@ -635,12 +631,8 @@ describe('display_list', () => { display_list(build_list(i => build_list(j => j, i), 5)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(null, list(0), list(0, 1), list(0, 1, 2), list(0, 1, 2, 3))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('standard acyclic with pairs', () => { @@ -649,16 +641,8 @@ describe('display_list', () => { display_list(build_list(i => build_list(j => pair(j, j), i), 5)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(null, - list([0, 0]), - list([0, 0], [1, 1]), - list([0, 0], [1, 1], [2, 2]), - list([0, 0], [1, 1], [2, 2], [3, 3]))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('standard acyclic with pairs 2', () => { @@ -667,16 +651,8 @@ describe('display_list', () => { display_list(build_list(i => build_list(j => pair(build_list(k => k, j), j), i), 5)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(null, - list([null, 0]), - list([null, 0], [list(0), 1]), - list([null, 0], [list(0), 1], [list(0, 1), 2]), - list([null, 0], [list(0), 1], [list(0, 1), 2], [list(0, 1, 2), 3]))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('returns argument', () => { @@ -686,7 +662,7 @@ describe('display_list', () => { xs === display_list(xs); // Note reference equality `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -706,7 +682,7 @@ describe('display_list', () => { xs === display_list(xs); // Note reference equality `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -716,12 +692,8 @@ describe('display_list', () => { display_list(build_list(i => i, 5), "build_list:"); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "build_list: list(0, 1, 2, 3, 4)", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('checks prepend type', () => { @@ -730,7 +702,7 @@ describe('display_list', () => { display_list(build_list(i => i, 5), true); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot( `"Line 1: TypeError: display_list expects the second argument to be a string"` ) @@ -746,26 +718,8 @@ describe('display_list', () => { display_list(parse('const twice = f => x => {const result = f(f(x)); return two;};')); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_4, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(\\"constant_declaration\\", - list(\\"name\\", \\"twice\\"), - list(\\"lambda_expression\\", - list(list(\\"name\\", \\"f\\")), - list(\\"return_statement\\", - list(\\"lambda_expression\\", - list(list(\\"name\\", \\"x\\")), - list(\\"block\\", - list(\\"sequence\\", - list(list(\\"constant_declaration\\", - list(\\"name\\", \\"result\\"), - list(\\"application\\", - list(\\"name\\", \\"f\\"), - list(list(\\"application\\", list(\\"name\\", \\"f\\"), list(list(\\"name\\", \\"x\\")))))), - list(\\"return_statement\\", list(\\"name\\", \\"two\\")))))))))", - ] - `) + { chapter: Chapter.SOURCE_4 } + ).toMatchInlineSnapshot(`Array []`) }) test('standard acyclic multiline', () => { @@ -774,31 +728,8 @@ describe('display_list', () => { display_list(build_list(i => build_list(j => j, i), 20)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(null, - list(0), - list(0, 1), - list(0, 1, 2), - list(0, 1, 2, 3), - list(0, 1, 2, 3, 4), - list(0, 1, 2, 3, 4, 5), - list(0, 1, 2, 3, 4, 5, 6), - list(0, 1, 2, 3, 4, 5, 6, 7), - list(0, 1, 2, 3, 4, 5, 6, 7, 8), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), - list(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('infinite list', () => { @@ -809,12 +740,8 @@ describe('display_list', () => { display_list(p); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - Array [ - "[1, ...]", - ] - `) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot(`Array []`) }) test('infinite list 2', () => { @@ -825,12 +752,8 @@ describe('display_list', () => { display_list(p); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - Array [ - "[1, [2, [3, ...]]]", - ] - `) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot(`Array []`) }) test('reusing lists', () => { @@ -842,12 +765,8 @@ describe('display_list', () => { display_list(p3); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(list(1), list(list(1), 1))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('reusing lists 2', () => { @@ -859,12 +778,8 @@ describe('display_list', () => { display_list(p3); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_2, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list(list(1), list(2, 1))", - ] - `) + { chapter: Chapter.SOURCE_2 } + ).toMatchInlineSnapshot(`Array []`) }) test('list of infinite list', () => { return expectDisplayResult( @@ -881,16 +796,8 @@ describe('display_list', () => { display_list(build_list(build_inf, 5)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list([0, ...], - [0, [1, ...]], - [0, [1, [2, ...]]], - [0, [1, [2, [3, ...]]]], - [0, [1, [2, [3, [4, ...]]]]])", - ] - `) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot(`Array []`) }) test('list of infinite list of list', () => { @@ -908,14 +815,8 @@ describe('display_list', () => { display_list(build_list(i => build_inf(i, i => build_list(i => i, i)), 3)); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - Array [ - "list([null, ...], - [null, [list(0), ...]], - [null, [list(0), [list(0, 1), ...]]])", - ] - `) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot(`Array []`) }) test('infinite list of list of infinite list', () => { @@ -933,15 +834,7 @@ describe('display_list', () => { display_list(build_inf(3, i => build_list(i => build_inf(i, i=>i), i))); 0; // suppress long result in snapshot `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatchInlineSnapshot(` - Array [ - "[ null, - [ list([0, ...]), - [ list([0, ...], [0, [1, ...]]), - [ list([0, ...], [0, [1, ...]], [0, [1, [2, ...]]]), - ...]]]]", - ] - `) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot(`Array []`) }) }) diff --git a/src/stdlib/__tests__/localImport.ts b/src/stdlib/__tests__/localImport.ts index 59658e031..f9826c9d3 100644 --- a/src/stdlib/__tests__/localImport.ts +++ b/src/stdlib/__tests__/localImport.ts @@ -15,7 +15,7 @@ describe('__access_named_export__', () => { const square = __access_named_export__(importedFile(), "square"); square(5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`25`) }) @@ -31,7 +31,7 @@ describe('__access_named_export__', () => { const square = __access_named_export__(importedFile(), "square"); square(5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`25`) }) @@ -45,7 +45,7 @@ describe('__access_named_export__', () => { } __access_named_export__(importedFile(), "identity"); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`undefined`) }) @@ -59,7 +59,7 @@ describe('__access_named_export__', () => { } __access_named_export__(importedFile(), "identity"); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`undefined`) }) }) @@ -76,7 +76,7 @@ describe('__access_export__', () => { const square = __access_export__(importedFile(), "square"); square(5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`25`) }) @@ -93,7 +93,7 @@ describe('__access_export__', () => { const square = __access_export__(importedFile(), "${defaultExportLookupName}"); square(5); `, - { chapter: Chapter.SOURCE_2, native: true } + { chapter: Chapter.SOURCE_2 } ).toMatchInlineSnapshot(`125`) }) }) diff --git a/src/stdlib/__tests__/misc.ts b/src/stdlib/__tests__/misc.ts index e0011efee..782e951ac 100644 --- a/src/stdlib/__tests__/misc.ts +++ b/src/stdlib/__tests__/misc.ts @@ -7,7 +7,7 @@ test('parse_int with valid args is ok, radix 2', () => { stripIndent` parse_int('1100101010101', 2); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(parseInt('1100101010101', 2)) }) @@ -16,7 +16,7 @@ test('parse_int with valid args is ok, radix 36', () => { stripIndent` parse_int('uu1', 36); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(parseInt('uu1', 36)) }) @@ -25,7 +25,7 @@ test('parse_int with valid args is ok, but invalid str for radix', () => { stripIndent` parse_int('uu1', 2); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(parseInt('uu1', 2)) }) @@ -112,7 +112,7 @@ test('arity with nullary function is ok', () => { stripIndent` arity(math_random); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(0) }) @@ -121,7 +121,7 @@ test('arity with function with parameters is ok', () => { stripIndent` arity(arity); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(1) }) @@ -130,7 +130,7 @@ test('arity ignores the rest parameter', () => { stripIndent` arity(display); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(1) }) @@ -142,7 +142,7 @@ test('arity with user-made function is ok', () => { } arity(test); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(2) }) @@ -151,7 +151,7 @@ test('arity with user-made lambda function is ok', () => { stripIndent` arity(x => x); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(1) }) @@ -160,7 +160,7 @@ test('arity with user-made nullary function is ok', () => { stripIndent` arity(() => undefined); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toBe(0) }) @@ -172,7 +172,7 @@ test('arity with user-made function with rest parameter is ok', () => { } arity(test); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toBe(0) }) @@ -181,6 +181,6 @@ test('arity with non-function arg f throws error', () => { stripIndent` arity('function'); `, - { chapter: Chapter.SOURCE_1, native: true } + { chapter: Chapter.SOURCE_1 } ).toMatchInlineSnapshot(`"Line 1: Error: arity expects a function as argument"`) }) diff --git a/src/stdlib/__tests__/parser.ts b/src/stdlib/__tests__/parser.ts index 800819ace..2b74c7263 100644 --- a/src/stdlib/__tests__/parser.ts +++ b/src/stdlib/__tests__/parser.ts @@ -7,7 +7,7 @@ test('Parses empty program', () => { stripIndent` stringify(parse(""), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -16,7 +16,7 @@ test('Parses literals', () => { stripIndent` stringify(parse("3; true; false; ''; \\"\\"; 'bob'; 1; 20;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -25,7 +25,7 @@ test('Parses name expression', () => { stripIndent` stringify(parse("x;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -34,7 +34,7 @@ test('Parses name expressions', () => { stripIndent` stringify(parse("x; moreNames; undefined;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -43,7 +43,7 @@ test('Parses infix expressions', () => { stripIndent` stringify(parse("3 + 5 === 8 || !true && false;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -52,7 +52,7 @@ test('Parses declaration statements', () => { stripIndent` stringify(parse("const x = 5; let y = x;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -61,7 +61,7 @@ test('Parses assignment statements', () => { stripIndent` stringify(parse("x = 5; x = x; if (true) { x = 5; } else {}"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -70,7 +70,7 @@ test('Parses if statements', () => { stripIndent` stringify(parse("if (true) { hi; } else { haha; } if (false) {} else {}"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -79,7 +79,7 @@ test('Parses multi-argument arrow function expressions properly', () => { stripIndent` stringify(parse("(x, y) => x + 1;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -88,7 +88,7 @@ test('Parses multi-argument arrow function expressions properly', () => { stripIndent` stringify(parse("(x, y) => x + 1;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -97,7 +97,7 @@ test('Parses multi-argument arrow function assignments properly', () => { stripIndent` stringify(parse("const y = (x, y) => x + 1;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -106,7 +106,7 @@ test('Parses arrow function expressions properly', () => { stripIndent` stringify(parse("x => x + 1;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -115,7 +115,7 @@ test('Parses arrow function assignments properly', () => { stripIndent` stringify(parse("const y = x => x + 1;"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -124,7 +124,7 @@ test('Parses function calls', () => { stripIndent` stringify(parse("f(x); thrice(thrice)(plus_one)(0);"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -133,7 +133,7 @@ test('Parses fibonacci', () => { stripIndent` stringify(parse("function fib(x) { return x <= 1 ? x : fib(x-1) + fib(x-2); } fib(4);"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) @@ -181,7 +181,7 @@ test('Parses loops', () => { break; }"), undefined, 2); `, - { chapter: Chapter.SOURCE_4, native: true } + { chapter: Chapter.SOURCE_4 } ) }) diff --git a/src/stdlib/__tests__/pylib.ts b/src/stdlib/__tests__/pylib.ts index 43d2e1299..22cee8780 100644 --- a/src/stdlib/__tests__/pylib.ts +++ b/src/stdlib/__tests__/pylib.ts @@ -7,7 +7,7 @@ test('adding two integers is ok', () => { stripIndent` 1 + 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(3n) }) @@ -16,7 +16,7 @@ test('adding two floats is ok', () => { stripIndent` 1.0 + 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(3) }) @@ -25,7 +25,7 @@ test('adding an integer and a float is ok', () => { stripIndent` 1.0 + 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(3) }) @@ -34,7 +34,7 @@ test('adding a string and an integer is ok', () => { stripIndent` "a" + 1 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual('a1') }) @@ -43,7 +43,7 @@ test('minusing two integers is ok', () => { stripIndent` 1 - 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(-1n) }) @@ -52,7 +52,7 @@ test('minusing two floats is ok', () => { stripIndent` 1.0 - 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(-1) }) @@ -61,7 +61,7 @@ test('minusing an integer from a float is ok', () => { stripIndent` 1.0 - 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(-1) }) @@ -70,7 +70,7 @@ test('multiplying integer and float is ok', () => { stripIndent` 1.0 * 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2) }) @@ -79,7 +79,7 @@ test('multiplying integer and integer is ok', () => { stripIndent` 1 * 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2n) }) @@ -88,7 +88,7 @@ test('multiplying float and float is ok', () => { stripIndent` 1.0 * 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2) }) @@ -97,7 +97,7 @@ test('cannot multiply non-number values', () => { stripIndent` True * 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toMatchInlineSnapshot(`"Line 1: Error: Invalid types for multiply operation: boolean, bigint"`) }) @@ -106,7 +106,7 @@ test('dividing integer and float is ok', () => { stripIndent` 2 / 1.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2) }) @@ -115,7 +115,7 @@ test('dividing integer and integer is ok', () => { stripIndent` 1 / 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(0.5) }) @@ -124,7 +124,7 @@ test('dividing float and float is ok', () => { stripIndent` 1.0 / 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(0.5) }) @@ -133,7 +133,7 @@ test('cannot divide non-number values', () => { stripIndent` "a" / 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toMatchInlineSnapshot( `"Line 1: Error: Expected number on left hand side of operation, got string."` ) @@ -144,7 +144,7 @@ test('modding integer and float is ok', () => { stripIndent` 2 % 1.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(0) }) @@ -153,7 +153,7 @@ test('modding integer and integer is ok', () => { stripIndent` 2 % 1 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(0n) }) @@ -162,7 +162,7 @@ test('modding float and float is ok', () => { stripIndent` 1.0 % 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(1.0) }) @@ -171,7 +171,7 @@ test('cannot mod non-number values', () => { stripIndent` "a" % 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toMatchInlineSnapshot( `"Line 1: Error: Expected number on left hand side of operation, got string."` ) @@ -182,7 +182,7 @@ test('powering integer and float is ok', () => { stripIndent` 2 ** 1.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2.0) }) @@ -191,7 +191,7 @@ test('powering integer and integer is ok', () => { stripIndent` 2 ** 1 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2n) }) @@ -200,7 +200,7 @@ test('powering float and float is ok', () => { stripIndent` 1.0 ** 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(1.0) }) @@ -209,7 +209,7 @@ test('cannot power non-number values', () => { stripIndent` "a" ** 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toMatchInlineSnapshot( `"Line 1: Error: Expected number on left hand side of operation, got string."` ) @@ -220,7 +220,7 @@ test('flooring integer and float is ok', () => { stripIndent` 2 // 1.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2n) }) @@ -229,7 +229,7 @@ test('flooring integer and integer is ok', () => { stripIndent` 2 // 1 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(2n) }) @@ -238,7 +238,7 @@ test('flooring float and float is ok', () => { stripIndent` 1.0 // 2.0 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toEqual(0n) }) @@ -247,7 +247,7 @@ test('cannot floor non-number values', () => { stripIndent` "a" // 2 `, - { chapter: Chapter.PYTHON_1, native: true } + { chapter: Chapter.PYTHON_1 } ).toMatchInlineSnapshot( `"Line 1: Error: Expected number on left hand side of operation, got string."` ) diff --git a/src/stdlib/__tests__/stream.ts b/src/stdlib/__tests__/stream.ts index c3e55ff7b..673962cd1 100644 --- a/src/stdlib/__tests__/stream.ts +++ b/src/stdlib/__tests__/stream.ts @@ -1,16 +1,15 @@ import { Chapter } from '../../types' import { stripIndent } from '../../utils/formatters' -import { expectParsedErrorNoSnapshot, expectResult } from '../../utils/testing' +import { expectParsedError, expectResult } from '../../utils/testing' describe('primitive stream functions', () => { test('empty stream is null', () => { - return expectResult('stream();', { chapter: Chapter.SOURCE_3, native: true }).toBe(null) + return expectResult('stream();', { chapter: Chapter.SOURCE_3 }).toBe(null) }) test('stream_tail works', () => { return expectResult(`head(stream_tail(stream(1, 2)));`, { - chapter: Chapter.SOURCE_3, - native: true + chapter: Chapter.SOURCE_3 }).toBe(2) }) @@ -19,22 +18,24 @@ describe('primitive stream functions', () => { stripIndent(` stream_tail(integers_from(0)); `), - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(` -Array [ - 1, - [Function], -] -`) + Array [ + 1, + [Function], + ] + `) }) test('infinite stream is infinite', () => { - return expectParsedErrorNoSnapshot( + return expectParsedError( stripIndent` stream_length(integers_from(0)); `, - { chapter: Chapter.SOURCE_3, native: true } - ).toMatch(/(Maximum call stack size exceeded){1,2}/) + { chapter: Chapter.SOURCE_3 } + ).toMatchInlineSnapshot( + `"Line 1: The error may have arisen from forcing the infinite stream: function integers_from."` + ) }, 15000) test('stream is properly created', () => { @@ -45,42 +46,40 @@ Array [ stream_for_each(item => {result[array_length(result)] = item;}, s); stream_ref(s,4)(22) === 22 && stream_ref(s,7)(pair('', '1')) === '1' && result; `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`false`) }) test('stream_to_list works for null', () => { return expectResult(`stream_to_list(null);`, { - chapter: Chapter.SOURCE_3, - native: true + chapter: Chapter.SOURCE_3 }).toMatchInlineSnapshot(`null`) }) test('stream_to_list works', () => { return expectResult(`stream_to_list(stream(1, true, 3, 4.4, [1, 2]));`, { - chapter: Chapter.SOURCE_3, - native: true + chapter: Chapter.SOURCE_3 }).toMatchInlineSnapshot(` -Array [ - 1, - Array [ - true, - Array [ - 3, - Array [ - 4.4, - Array [ - Array [ - 1, - 2, - ], - null, - ], - ], - ], - ], -] -`) + Array [ + 1, + Array [ + true, + Array [ + 3, + Array [ + 4.4, + Array [ + Array [ + 1, + 2, + ], + null, + ], + ], + ], + ], + ] + `) }) }) @@ -93,7 +92,7 @@ test('for_each', () => { }, stream(1, 2, 3)); sum; `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`6`) }) @@ -102,7 +101,7 @@ test('map', () => { stripIndent` equal(stream_to_list(stream_map(x => 2 * x, stream(12, 11, 3))), list(24, 22, 6)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -115,7 +114,7 @@ test('filter', () => { ) , list(2, 1, 3, 4, 2)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -124,7 +123,7 @@ test('build_list', () => { stripIndent` equal(stream_to_list(build_stream(x => x * x, 5)), list(0, 1, 4, 9, 16)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -136,7 +135,7 @@ test('reverse', () => { stream("string", null, undefined, null, 123))), list(123, null, undefined, null, "string")); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -146,7 +145,7 @@ test('append', () => { equal(stream_to_list(stream_append(stream("string", 123), stream(456, null, undefined))) , list("string", 123, 456, null, undefined)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -157,7 +156,7 @@ test('member', () => { stream_to_list(stream_member("string", stream(1, 2, 3, "string", 123, 456, null, undefined))), list("string", 123, 456, null, undefined)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -166,7 +165,7 @@ test('remove', () => { stripIndent` stream_remove(1, stream(1)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`null`) }) @@ -175,13 +174,13 @@ test('remove not found', () => { stripIndent` stream_to_list(stream_remove(2, stream(1))); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(` -Array [ - 1, - null, -] -`) + Array [ + 1, + null, + ] + `) }) test('remove_all', () => { @@ -190,7 +189,7 @@ test('remove_all', () => { equal(stream_to_list(stream_remove_all(1, stream(1, 2, 3, 4, 1, 1, "1", 5, 1, 1, 6))), list(2, 3, 4, "1", 5, 6)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -199,7 +198,7 @@ test('remove_all not found', () => { stripIndent` equal(stream_to_list(stream_remove_all(1, stream(2, 3, "1"))), list(2, 3, "1")); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -208,7 +207,7 @@ test('enum_list', () => { stripIndent` equal(stream_to_list(enum_stream(1, 5)), list(1, 2, 3, 4, 5)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -217,7 +216,7 @@ test('enum_list with floats', () => { stripIndent` equal(stream_to_list(enum_stream(1.5, 5)), list(1.5, 2.5, 3.5, 4.5)); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`true`) }) @@ -226,6 +225,6 @@ test('list_ref', () => { stripIndent` stream_ref(stream(1, 2, 3, "4", 4), 4); `, - { chapter: Chapter.SOURCE_3, native: true } + { chapter: Chapter.SOURCE_3 } ).toMatchInlineSnapshot(`4`) }) diff --git a/src/stdlib/inspector.ts b/src/stdlib/inspector.ts index 85a6fecb3..8eeeea12f 100644 --- a/src/stdlib/inspector.ts +++ b/src/stdlib/inspector.ts @@ -1,29 +1,9 @@ -import { Context, Result } from '..' -import { Node, Scheduler, Value } from '../types' - -export const saveState = ( - context: Context, - it: IterableIterator, - scheduler: Scheduler -): void => { - context.debugger.state.it = it - context.debugger.state.scheduler = scheduler -} +import type { Context, Node } from '../types' export const setBreakpointAtLine = (lines: string[]): void => { breakpoints = lines } -export const manualToggleDebugger = (context: Context): Result => { - context.runtime.break = true - return { - status: 'suspended', - scheduler: context.debugger.state.scheduler, - it: context.debugger.state.it, - context - } -} - let breakpoints: string[] = [] let moved: boolean = true let prevStoppedLine: number = -1 diff --git a/src/stdlib/misc.ts b/src/stdlib/misc.ts index bff859425..312c08070 100644 --- a/src/stdlib/misc.ts +++ b/src/stdlib/misc.ts @@ -1,4 +1,4 @@ -import Closure from '../interpreter/closure' +import Closure from '../cse-machine/closure' import { Context, Value } from '../types' import { stringify } from '../utils/stringify' diff --git a/src/stepper/__tests__/stepper.ts b/src/stepper/__tests__/stepper.ts index 0e6f6a3dd..b4f843897 100644 --- a/src/stepper/__tests__/stepper.ts +++ b/src/stepper/__tests__/stepper.ts @@ -1,6 +1,6 @@ import type es from 'estree' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Context, substituterNodes } from '../../types' import { codify, getEvaluationSteps } from '../stepper' diff --git a/src/stepper/converter.ts b/src/stepper/converter.ts index f0f508802..d3be23938 100644 --- a/src/stepper/converter.ts +++ b/src/stepper/converter.ts @@ -1,6 +1,6 @@ -import * as es from 'estree' +import type es from 'estree' -import { mockContext, mockImportDeclaration } from '../mocks/context' +import { mockContext, mockImportDeclaration } from '../utils/testing/mocks' import { parse } from '../parser/parser' import { Chapter, Context, substituterNodes } from '../types' import * as builtin from './lib' diff --git a/src/transpiler/__tests__/native.ts b/src/transpiler/__tests__/native.ts index 9a4e23427..2acdffd28 100644 --- a/src/transpiler/__tests__/native.ts +++ b/src/transpiler/__tests__/native.ts @@ -1,5 +1,5 @@ import { runInContext } from '../../index' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter, Finished } from '../../types' import { stripIndent } from '../../utils/formatters' import { expectNativeToTimeoutAndError } from '../../utils/testing' diff --git a/src/transpiler/__tests__/transpiled-code.ts b/src/transpiler/__tests__/transpiled-code.ts index 5b54c21cb..01359dafe 100644 --- a/src/transpiler/__tests__/transpiled-code.ts +++ b/src/transpiler/__tests__/transpiled-code.ts @@ -1,8 +1,8 @@ -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter } from '../../types' import * as ast from '../../utils/ast/astCreator' -import { sanitizeAST } from '../../utils/ast/sanitizer' +import { sanitizeAST } from '../../utils/testing/sanitizer' import { stripIndent } from '../../utils/formatters' import { transformImportDeclarations, transpile } from '../transpiler' diff --git a/src/typeChecker/__tests__/source1Typed.test.ts b/src/typeChecker/__tests__/source1Typed.test.ts index d682d554d..07827fb12 100644 --- a/src/typeChecker/__tests__/source1Typed.test.ts +++ b/src/typeChecker/__tests__/source1Typed.test.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Variant } from '../../types' diff --git a/src/typeChecker/__tests__/source2Typed.test.ts b/src/typeChecker/__tests__/source2Typed.test.ts index f46a26192..d537417b3 100644 --- a/src/typeChecker/__tests__/source2Typed.test.ts +++ b/src/typeChecker/__tests__/source2Typed.test.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Variant } from '../../types' diff --git a/src/typeChecker/__tests__/source3Typed.test.ts b/src/typeChecker/__tests__/source3Typed.test.ts index c90798083..05330e3fe 100644 --- a/src/typeChecker/__tests__/source3Typed.test.ts +++ b/src/typeChecker/__tests__/source3Typed.test.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Variant } from '../../types' diff --git a/src/typeChecker/__tests__/source4Typed.test.ts b/src/typeChecker/__tests__/source4Typed.test.ts index 979e6dd89..19a4a175b 100644 --- a/src/typeChecker/__tests__/source4Typed.test.ts +++ b/src/typeChecker/__tests__/source4Typed.test.ts @@ -1,5 +1,5 @@ import { parseError } from '../..' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, Variant } from '../../types' diff --git a/src/typeChecker/__tests__/source4TypedModules.test.ts b/src/typeChecker/__tests__/source4TypedModules.test.ts index f2449a0a2..d546cb29f 100644 --- a/src/typeChecker/__tests__/source4TypedModules.test.ts +++ b/src/typeChecker/__tests__/source4TypedModules.test.ts @@ -1,4 +1,4 @@ -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { Chapter, Variant } from '../../types' import { parse } from '../../parser/parser' import { parseError } from '../../index' diff --git a/src/types.ts b/src/types.ts index 81456b691..4473caa88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -64,7 +64,7 @@ export interface Comment { loc: SourceLocation | undefined } -export type ExecutionMethod = 'native' | 'interpreter' | 'auto' | 'cse-machine' +export type ExecutionMethod = 'native' | 'auto' | 'cse-machine' export enum Chapter { SOURCE_1 = 1, @@ -94,7 +94,6 @@ export enum Variant { TYPED = 'typed', NATIVE = 'native', WASM = 'wasm', - CONCURRENT = 'concurrent', EXPLICIT_CONTROL = 'explicit-control' } @@ -168,7 +167,6 @@ export interface Context { status: boolean state: { it: IterableIterator - scheduler: Scheduler } } @@ -274,23 +272,12 @@ export interface Finished { // field instead } -export interface Suspended { - status: 'suspended' - it: IterableIterator - scheduler: Scheduler - context: Context -} - export interface SuspendedCseEval { status: 'suspended-cse-eval' context: Context } -export type Result = Suspended | Finished | Error | SuspendedCseEval - -export interface Scheduler { - run(it: IterableIterator, context: Context): Promise -} +export type Result = Finished | Error | SuspendedCseEval /** * StatementSequence : A sequence of statements not surrounded by braces. @@ -510,3 +497,5 @@ export type RecursivePartial = T extends Array [K in keyof T]: RecursivePartial }> : T + +export type NodeTypeToNode = Extract diff --git a/src/utils/__tests__/rttc.ts b/src/utils/__tests__/rttc.ts index 7a2a39a3f..1f42fdacd 100644 --- a/src/utils/__tests__/rttc.ts +++ b/src/utils/__tests__/rttc.ts @@ -1,6 +1,6 @@ import { BinaryOperator, UnaryOperator } from 'estree' -import { mockClosure, mockRuntimeContext } from '../../mocks/context' +import { mockClosure, mockRuntimeContext } from '../testing/mocks' import { Chapter, Value } from '../../types' import * as rttc from '../rttc' diff --git a/src/utils/stringify.ts b/src/utils/stringify.ts index b8e7f6aed..f5007c4b8 100644 --- a/src/utils/stringify.ts +++ b/src/utils/stringify.ts @@ -1,5 +1,5 @@ import { MAX_LIST_DISPLAY_LENGTH } from '../constants' -import Closure from '../interpreter/closure' +import Closure from '../cse-machine/closure' import { Type, Value } from '../types' export interface ArrayLike { diff --git a/src/utils/testing.ts b/src/utils/testing.ts deleted file mode 100644 index f26de4bdc..000000000 --- a/src/utils/testing.ts +++ /dev/null @@ -1,371 +0,0 @@ -import type { MockedFunction } from 'jest-mock' - -import createContext, { defineBuiltin } from '../createContext' -import { parseError, Result, runInContext } from '../index' -import { mockContext } from '../mocks/context' -import { ImportOptions } from '../modules/moduleTypes' -import { parse } from '../parser/parser' -import { transpile } from '../transpiler/transpiler' -import { - Chapter, - Context, - CustomBuiltIns, - SourceError, - Value, - Variant, - type Finished -} from '../types' -import { stringify } from './stringify' - -export interface CodeSnippetTestCase { - name: string - snippet: string - value: any - errors: SourceError[] -} - -export interface TestContext extends Context { - displayResult: string[] - promptResult: string[] - alertResult: string[] - visualiseListResult: Value[] -} - -interface TestBuiltins { - [builtinName: string]: any -} - -interface TestResult { - code: string - displayResult: string[] - alertResult: string[] - visualiseListResult: any[] - errors?: SourceError[] - numErrors: number - parsedErrors: string - resultStatus: string - result: Value -} - -interface TestOptions { - context?: TestContext - chapter?: Chapter - variant?: Variant - testBuiltins?: TestBuiltins - native?: boolean - showTranspiledCode?: boolean - showErrorJSON?: boolean - importOptions?: Partial -} - -export function createTestContext({ - context, - chapter = Chapter.SOURCE_1, - variant = Variant.DEFAULT, - testBuiltins = {} -}: { - context?: TestContext - chapter?: Chapter - variant?: Variant - testBuiltins?: TestBuiltins -} = {}): TestContext { - if (context !== undefined) { - return context - } else { - const testContext: TestContext = { - ...createContext(chapter, variant, [], undefined, { - rawDisplay: (str1, str2, _externalContext) => { - testContext.displayResult.push((str2 === undefined ? '' : str2 + ' ') + str1) - return str1 - }, - prompt: (str, _externalContext) => { - testContext.promptResult.push(str) - return null - }, - alert: (str, _externalContext) => { - testContext.alertResult.push(str) - }, - visualiseList: value => { - testContext.visualiseListResult.push(value) - } - } as CustomBuiltIns), - displayResult: [], - promptResult: [], - alertResult: [], - visualiseListResult: [] - } - Object.entries(testBuiltins).forEach(([key, value]) => defineBuiltin(testContext, key, value)) - - return testContext - } -} - -async function testInContext(code: string, options: TestOptions): Promise { - const interpretedTestContext = createTestContext(options) - const scheduler = 'preemptive' - const getTestResult = (context: TestContext, result: Result) => { - const testResult = { - code, - displayResult: context.displayResult, - alertResult: context.alertResult, - visualiseListResult: context.visualiseListResult, - numErrors: context.errors.length, - parsedErrors: parseError(context.errors), - resultStatus: result.status, - result: result.status === 'finished' ? result.value : undefined - } - if (options.showErrorJSON) { - testResult['errors'] = context.errors - } - return testResult - } - const interpretedResult = getTestResult( - interpretedTestContext, - await runInContext(code, interpretedTestContext, { - scheduler, - executionMethod: 'interpreter', - variant: options.variant - }) - ) - if (options.native) { - const nativeTestContext = createTestContext(options) - let pretranspiled: string = '' - let transpiled: string = '' - const parsed = parse(code, nativeTestContext)! - // Reset errors in context so as not to interfere with actual run. - nativeTestContext.errors = [] - if (parsed === undefined) { - pretranspiled = 'parseError' - } else { - try { - ;({ transpiled } = transpile(parsed, nativeTestContext)) - // replace declaration of builtins since they're repetitive - transpiled = transpiled.replace(/\n const \w+ = nativeStorage\..*;/g, '') - transpiled = transpiled.replace(/\n\s*const \w+ = .*\.operators\..*;/g, '') - } catch { - transpiled = 'parseError' - } - } - const nativeResult = getTestResult( - nativeTestContext, - await runInContext(code, nativeTestContext, { - scheduler, - executionMethod: 'native', - variant: options.variant - }) - ) - const propertiesThatShouldBeEqual = [ - 'code', - 'displayResult', - 'alertResult', - 'parsedErrors', - 'result' - ] - const diff = {} - for (const property of propertiesThatShouldBeEqual) { - const nativeValue = stringify(nativeResult[property]) - const interpretedValue = stringify(interpretedResult[property]) - if (nativeValue !== interpretedValue) { - diff[property] = `native:${nativeValue}\ninterpreted:${interpretedValue}` - } - } - if (options.showTranspiledCode) { - return { ...interpretedResult, ...diff, pretranspiled, transpiled } as TestResult - } else { - return { ...interpretedResult, ...diff } as TestResult - } - } else { - return interpretedResult - } -} - -export async function testSuccess(code: string, options: TestOptions = { native: false }) { - const testResult = await testInContext(code, options) - expect(testResult.parsedErrors).toBe('') - expect(testResult.resultStatus).toBe('finished') - return testResult -} - -export async function testSuccessWithErrors( - code: string, - options: TestOptions = { native: false } -) { - const testResult = await testInContext(code, options) - expect(testResult.numErrors).not.toEqual(0) - expect(testResult.resultStatus).toBe('finished') - return testResult -} - -export async function testFailure(code: string, options: TestOptions = { native: false }) { - const testResult = await testInContext(code, options) - expect(testResult.numErrors).not.toEqual(0) - expect(testResult.resultStatus).toBe('error') - return testResult -} - -export function snapshot( - propertyMatchers: Partial, - snapshotName?: string -): (testResult: TestResult) => TestResult -export function snapshot( - snapshotName?: string, - arg2?: string -): (testResult: TestResult) => TestResult -export function snapshot(arg1?: any, arg2?: any): (testResult: TestResult) => TestResult { - if (arg2) { - return testResult => { - expect(testResult).toMatchSnapshot(arg1!, arg2) - return testResult - } - } else if (arg1) { - return testResult => { - expect(testResult).toMatchSnapshot(arg1!) - return testResult - } - } else { - return testResult => { - return testResult - } - } -} - -export function snapshotSuccess(code: string, options: TestOptions, snapshotName?: string) { - return testSuccess(code, options).then(snapshot(snapshotName)) -} - -export function snapshotWarning(code: string, options: TestOptions, snapshotName: string) { - return testSuccessWithErrors(code, options).then(snapshot(snapshotName)) -} - -export function snapshotFailure(code: string, options: TestOptions, snapshotName: string) { - return testFailure(code, options).then(snapshot(snapshotName)) -} - -export function expectDisplayResult(code: string, options: TestOptions = {}) { - return expect( - testSuccess(code, options) - .then(snapshot('expectDisplayResult')) - .then(testResult => testResult.displayResult!) - .catch(e => console.log(e)) - ).resolves -} - -export function expectVisualiseListResult(code: string, options: TestOptions = {}) { - return expect( - testSuccess(code, options) - .then(snapshot('expectVisualiseListResult')) - .then(testResult => testResult.visualiseListResult) - .catch(e => console.log(e)) - ).resolves -} - -// for use in concurrent testing -export async function getDisplayResult(code: string, options: TestOptions = {}) { - return await testSuccess(code, options).then(testResult => testResult.displayResult!) -} - -export function expectResult(code: string, options: TestOptions = {}) { - return expect( - testSuccess(code, options) - .then(snapshot('expectResult')) - .then(testResult => testResult.result) - ).resolves -} - -export function expectParsedErrorNoErrorSnapshot(code: string, options: TestOptions = {}) { - options.showErrorJSON = false - return expect( - testFailure(code, options) - .then(snapshot('expectParsedErrorNoErrorSnapshot')) - .then(testResult => testResult.parsedErrors) - ).resolves -} - -export function expectParsedError(code: string, options: TestOptions = {}) { - return expect( - testFailure(code, options) - .then(snapshot('expectParsedError')) - .then(testResult => testResult.parsedErrors) - ).resolves -} - -export function expectDifferentParsedErrors( - code1: string, - code2: string, - options: TestOptions = {} -) { - return expect( - testFailure(code1, options).then(error1 => { - expect( - testFailure(code2, options).then(error2 => { - return expect(error1).not.toEqual(error2) - }) - ) - }) - ).resolves -} - -export function expectWarning(code: string, options: TestOptions = {}) { - return expect( - testSuccessWithErrors(code, options) - .then(snapshot('expectWarning')) - .then(testResult => testResult.parsedErrors) - ).resolves -} - -export function expectParsedErrorNoSnapshot(code: string, options: TestOptions = {}) { - return expect(testFailure(code, options).then(testResult => testResult.parsedErrors)).resolves -} - -function evalWithBuiltins(code: string, testBuiltins: TestBuiltins = {}) { - // Ugly, but if you know how to `eval` code with some builtins attached, please change this. - let evalstring = '' - for (const key in testBuiltins) { - if (testBuiltins.hasOwnProperty(key)) { - evalstring = evalstring + 'const ' + key + ' = testBuiltins.' + key + '; ' - } - } - // tslint:disable-next-line:no-eval - return eval(evalstring + code) -} - -export function expectToMatchJS(code: string, options: TestOptions = {}) { - return testSuccess(code, options) - .then(snapshot('expect to match JS')) - .then(testResult => - expect(testResult.result).toEqual(evalWithBuiltins(code, options.testBuiltins)) - ) -} - -export function expectToLooselyMatchJS(code: string, options: TestOptions = {}) { - return testSuccess(code, options) - .then(snapshot('expect to loosely match JS')) - .then(testResult => - expect(testResult.result.replace(/ /g, '')).toEqual( - evalWithBuiltins(code, options.testBuiltins).replace(/ /g, '') - ) - ) -} - -export async function expectNativeToTimeoutAndError(code: string, timeout: number) { - const start = Date.now() - const context = mockContext(Chapter.SOURCE_4) - const promise = runInContext(code, context, { - scheduler: 'preemptive', - executionMethod: 'native', - throwInfiniteLoops: false - }) - await promise - const timeTaken = Date.now() - start - expect(timeTaken).toBeLessThan(timeout * 5) - expect(timeTaken).toBeGreaterThanOrEqual(timeout) - return parseError(context.errors) -} - -export function asMockedFunc any>(func: T) { - return func as MockedFunction -} - -export function expectFinishedResult(result: Result): asserts result is Finished { - expect(result.status).toEqual('finished') -} diff --git a/src/utils/testing/__tests__/testing.ts b/src/utils/testing/__tests__/testing.ts new file mode 100644 index 000000000..68ee9831b --- /dev/null +++ b/src/utils/testing/__tests__/testing.ts @@ -0,0 +1,47 @@ +import { createTestContext } from '..' +import { Chapter, Variant } from '../../../types' +import { processTestOptions } from '../misc' +import type { TestOptions } from '../types' + +describe('Test processRawOptions', () => { + const options: [string, TestOptions, TestOptions][] = [ + ['Chapter Number is a valid TestOption', Chapter.SOURCE_4, { chapter: Chapter.SOURCE_4 }], + [ + 'Specifying chapter number in options object', + { chapter: Chapter.SOURCE_4 }, + { chapter: Chapter.SOURCE_4 } + ] + ] + test.each(options)('%s', (_, value, expected) => { + expect(processTestOptions(value)).toEqual(expected) + }) +}) + +describe('Testing createTestContext', () => { + test('Providing no test options runs default variant and Source 1', () => { + const context = createTestContext() + expect(context.chapter).toEqual(Chapter.SOURCE_1) + expect(context.variant).toEqual(Variant.DEFAULT) + }) + + test('Providing a chaper runs default variant and that chapter', () => { + const context = createTestContext(Chapter.SOURCE_3) + expect(context.chapter).toEqual(Chapter.SOURCE_3) + expect(context.variant).toEqual(Variant.DEFAULT) + }) + + test('Specifying variant but not chapter should use Source 1', () => { + const context = createTestContext({ variant: Variant.EXPLICIT_CONTROL }) + expect(context.chapter).toEqual(Chapter.SOURCE_1) + expect(context.variant).toEqual(Variant.EXPLICIT_CONTROL) + }) + + test('If both chapter and variant are specified, both are used', () => { + const context = createTestContext({ + chapter: Chapter.SOURCE_4, + variant: Variant.DEFAULT + }) + expect(context.chapter).toEqual(Chapter.SOURCE_4) + expect(context.variant).toEqual(Variant.DEFAULT) + }) +}) diff --git a/src/utils/testing/index.ts b/src/utils/testing/index.ts new file mode 100644 index 000000000..a146e701d --- /dev/null +++ b/src/utils/testing/index.ts @@ -0,0 +1,172 @@ +import { Chapter, type CustomBuiltIns } from '../../types' +import { parseError, runInContext } from '../..' +import createContext, { defineBuiltin } from '../../createContext' +import { expectFinishedResult, processTestOptions } from './misc' +import { mockContext } from './mocks' +import type { TestContext, TestOptions, TestResults } from './types' + +export function createTestContext(rawOptions: TestOptions = {}): TestContext { + const { chapter, variant, testBuiltins }: Exclude = + typeof rawOptions === 'number' + ? { + chapter: rawOptions + } + : rawOptions + + const testContext: TestResults = { + displayResult: [], + promptResult: [], + alertResult: [], + visualiseListResult: [] + } + + const customBuiltIns: CustomBuiltIns = { + rawDisplay(str1, str2, _externalContext) { + testContext.displayResult.push((str2 === undefined ? '' : str2 + ' ') + str1) + return str1 + }, + prompt(str, _externalContext) { + testContext.promptResult.push(str) + return null + }, + alert(str, _externalContext) { + testContext.alertResult.push(str) + }, + visualiseList(value) { + testContext.visualiseListResult.push(value) + } + } + + const evalContext = createContext(chapter, variant, [], undefined, customBuiltIns) + Object.entries(testBuiltins ?? {}).forEach(([key, value]) => + defineBuiltin(evalContext, key, value) + ) + + return { + ...evalContext, + displayResult: [], + promptResult: [], + alertResult: [], + visualiseListResult: [] + } +} + +/** + * Convenience wrapper for testing multiple cases with the same + * test function + */ +export function testMultipleCases>( + cases: [string, ...T][], + tester: (args: T, i: number) => void | Promise, + includeIndex?: boolean, + timeout?: number +) { + const withIndex = cases.map(([desc, ...c], i) => { + const newDesc = includeIndex ? `${i + 1}. ${desc}` : desc + return [newDesc, i, ...c] as [string, number, ...T] + }) + test.each(withIndex)('%s', (_, i, ...args) => tester(args, i), timeout) +} + +async function testInContext(code: string, rawOptions: TestOptions) { + const options = processTestOptions(rawOptions) + const context = createTestContext(options) + const result = await runInContext(code, context) + return { + context, + result + } +} + +/** + * Run the given code and expect it to finish without errors + * @returns Context and result of test + */ +export async function testSuccess(code: string, options: TestOptions = {}) { + const { context, result } = await testInContext(code, options) + if (result.status !== 'finished') { + console.log(context.errors) + } + + expectFinishedResult(result) + return { + context, + result + } +} + +/** + * Run the given code and expect it to finish with errors + * @returns String value of parsed errors + */ +export async function testFailure(code: string, options: TestOptions = {}) { + const res = await testInContext(code, options) + expect(res.result.status).toEqual('error') + return parseError(res.context.errors) +} + +/** + * Run the given code and expect it to finish without errors. Use + * as if using `expect()` + */ +export function expectResult(code: string, options: TestOptions = {}) { + return expect( + testInContext(code, options).then(({ result, context }) => { + if (result.status === 'error') { + console.log(context.errors) + } + expectFinishedResult(result) + return result.value + }) + ).resolves +} + +/** + * Expect the code to error, then test the parsed error value. Use as if using + * `expect` + */ +export function expectParsedError(code: string, options: TestOptions = {}, verbose?: boolean) { + return expect( + testInContext(code, options).then(({ result, context }) => { + expect(result.status).toEqual('error') + return parseError(context.errors, verbose) + }) + ).resolves +} + +export async function expectNativeToTimeoutAndError(code: string, timeout: number) { + const start = Date.now() + const context = mockContext(Chapter.SOURCE_4) + const promise = runInContext(code, context, { + executionMethod: 'native', + throwInfiniteLoops: false + }) + await promise + const timeTaken = Date.now() - start + expect(timeTaken).toBeLessThan(timeout * 5) + expect(timeTaken).toBeGreaterThanOrEqual(timeout) + return parseError(context.errors) +} + +/** + * Run the given code, expect it to finish without errors and also match a snapshot + */ +export async function snapshotSuccess(code: string, options: TestOptions = {}) { + const results = await testSuccess(code, options) + expect(results).toMatchSnapshot() + return results +} + +/** + * Run the given code, expect it to finish with errors and that those errors match a snapshot + */ +export async function snapshotFailure(code: string, options: TestOptions = {}) { + const results = await testFailure(code, options) + expect(results).toMatchSnapshot() + return results +} + +export function expectDisplayResult(code: string, options: TestOptions = {}) { + return expect(testSuccess(code, options).then(({ context: { displayResult } }) => displayResult)) + .resolves +} diff --git a/src/utils/testing/misc.ts b/src/utils/testing/misc.ts new file mode 100644 index 000000000..7a6e3aed2 --- /dev/null +++ b/src/utils/testing/misc.ts @@ -0,0 +1,65 @@ +import type { MockedFunction } from 'jest-mock' +import type { Result } from '../..' +import type { Finished, Value, Node, NodeTypeToNode, Chapter } from '../../types' +import type { TestBuiltins, TestOptions } from './types' + +/** + * Convert the options provided by the user for each test into the full options + * used by the testing system + */ +export function processTestOptions(rawOptions: TestOptions = {}): Exclude { + return typeof rawOptions === 'number' + ? { + chapter: rawOptions + } + : rawOptions +} + +/** + * Wrapper around the MockedFunction type to provide type checking + * for mocked functions + */ +export function asMockedFunc any>(func: T) { + return func as MockedFunction +} + +export function expectTrue(cond: boolean): asserts cond { + expect(cond).toEqual(true) +} + +/** + * Asserts that the provided result is a `Finished` + */ +export function expectFinishedResult(result: Result): asserts result is Finished { + expect(result.status).toEqual('finished') +} + +/** + * Assers that the provided result is both `Finished` and is equal to the given value + */ +export function expectFinishedResultValue(result: Result, value: Value) { + expectFinishedResult(result) + expect(result.value).toEqual(value) +} + +/** + * Type safe assertion. Expects the given Node to have the provided type + */ +export function expectNodeType( + typeStr: T, + node: Node +): asserts node is NodeTypeToNode { + expect(node.type).toEqual(typeStr) +} + +/** + * Calls `eval` on the provided code with the provided builtins + */ +export function evalWithBuiltins(code: string, testBuiltins: TestBuiltins = {}) { + // Ugly, but if you know how to `eval` code with some builtins attached, please change this. + const builtins = Object.keys(testBuiltins).map(key => `const ${key} = testBuiltins.${key};`) + const evalstring = builtins.join('\n') + code + + // tslint:disable-next-line:no-eval + return eval(evalstring + code) +} diff --git a/src/mocks/context.ts b/src/utils/testing/mocks.ts similarity index 64% rename from src/mocks/context.ts rename to src/utils/testing/mocks.ts index 32bfcda21..75bdd2867 100644 --- a/src/mocks/context.ts +++ b/src/utils/testing/mocks.ts @@ -1,11 +1,10 @@ import * as es from 'estree' -import createContext, { EnvTree } from '../createContext' -import OldClosure from '../interpreter/closure' -import Closure from '../cse-machine/closure' -import { createBlockEnvironment } from '../interpreter/interpreter' -import { Chapter, Context, Environment, Variant } from '../types' -import { Transformers } from '../cse-machine/interpreter' +import createContext, { EnvTree } from '../../createContext' +import Closure from '../../cse-machine/closure' +import { Chapter, Context, Environment, Variant } from '../../types' +import { Transformers } from '../../cse-machine/interpreter' +import { createBlockEnvironment } from '../../cse-machine/utils' export function mockContext( chapter: Chapter = Chapter.SOURCE_1, @@ -65,28 +64,9 @@ export function mockRuntimeContext(): Context { return context } -export function mockClosure(cseMachineClosure: true): Closure -export function mockClosure(cseMachineClosure?: false): OldClosure -export function mockClosure(cseMachineClosure?: boolean): Closure | OldClosure { +export function mockClosure(): Closure { const context = createContext() - if (cseMachineClosure) { - return new Closure( - { - type: 'ArrowFunctionExpression', - expression: true, - loc: null, - params: [], - body: { - type: 'BlockStatement', - body: [] - } - } as es.ArrowFunctionExpression, - mockEnvironment(context), - mockTransformers(), - context - ) - } - return new OldClosure( + return new Closure( { type: 'ArrowFunctionExpression', expression: true, @@ -98,6 +78,7 @@ export function mockClosure(cseMachineClosure?: boolean): Closure | OldClosure { } } as es.ArrowFunctionExpression, mockEnvironment(context), + mockTransformers(), context ) } diff --git a/src/utils/ast/sanitizer.ts b/src/utils/testing/sanitizer.ts similarity index 100% rename from src/utils/ast/sanitizer.ts rename to src/utils/testing/sanitizer.ts diff --git a/src/utils/testing/types.ts b/src/utils/testing/types.ts new file mode 100644 index 000000000..0278344a0 --- /dev/null +++ b/src/utils/testing/types.ts @@ -0,0 +1,23 @@ +import type { Context } from '../..' +import { Chapter, Variant, type Value } from '../../types' + +export type TestOptions = + | { + chapter?: Chapter + variant?: Variant + testBuiltins?: TestBuiltins + } + | Chapter + +export interface TestResults { + displayResult: string[] + promptResult: string[] + alertResult: string[] + visualiseListResult: Value[] +} + +export type TestContext = Context & TestResults + +export interface TestBuiltins { + [builtinName: string]: any +} diff --git a/src/validator/__tests__/__snapshots__/validator.ts.snap b/src/validator/__tests__/__snapshots__/validator.ts.snap index 8c007e639..2e943df29 100644 --- a/src/validator/__tests__/__snapshots__/validator.ts.snap +++ b/src/validator/__tests__/__snapshots__/validator.ts.snap @@ -1,37 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`for loop variable cannot be reassigned in closure: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 10; i = i + 1) { - function f() { - i = 10; - } -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 3: Assignment to a for loop variable in the for loop is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`for loop variable cannot be reassigned: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 10; i = i + 1) { - i = 10; -}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Assignment to a for loop variable in the for loop is not allowed.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - exports[`testing typability 1`] = ` Node { "body": Array [ diff --git a/src/validator/__tests__/validator.ts b/src/validator/__tests__/validator.ts index b7bee3154..eb65dedf3 100644 --- a/src/validator/__tests__/validator.ts +++ b/src/validator/__tests__/validator.ts @@ -1,6 +1,6 @@ import * as es from 'estree' -import { mockContext } from '../../mocks/context' +import { mockContext } from '../../utils/testing/mocks' import { parse } from '../../parser/parser' import { Chapter, NodeWithInferredType } from '../../types' import { getVariableDeclarationName } from '../../utils/ast/astCreator' diff --git a/src/vm/__tests__/__snapshots__/svml-machine.ts.snap b/src/vm/__tests__/__snapshots__/svml-machine.ts.snap deleted file mode 100644 index 811090fcb..000000000 --- a/src/vm/__tests__/__snapshots__/svml-machine.ts.snap +++ /dev/null @@ -1,1735 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`primitive opcodes binary handler: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(math_pow(2,3));", - "displayResult": Array [ - "8", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes concurrent CLEAR fails for ill-typed arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "clear(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected array, got number for clear.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes concurrent CLEAR works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = list(true); -display(head(x)); -clear(x); -display(head(x));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes concurrent TEST_AND_SET fails for ill-typed arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "test_and_set(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected array, got number for test_and_set.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes concurrent TEST_AND_SET works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = list(false); -display(head(x)); -test_and_set(x); -display(head(x));", - "displayResult": Array [ - "false", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes math constants: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(Infinity); -display(NaN);", - "displayResult": Array [ - "Infinity", - "NaN", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented ARITY fails for ill-typed argument: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "arity(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected closure, got number for arity.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented ARITY works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(arity(math_random)); -display(arity(accumulate)); -display(arity(display)); -display(arity((x, y) => x)); -function f() {} -display(arity(f));", - "displayResult": Array [ - "0", - "3", - "0", - "2", - "0", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented ARRAY_LEN fails for ill-typed argument: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "array_length(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected array, got number for array_length.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented ARRAY_LEN works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const arr = []; -const arr1 = [1,2,3]; -const p = pair(1,2); -display(array_length(arr)); -display(array_length(arr1)); -arr[100] = 100; -display(array_length(arr)); -display(array_length(p));", - "displayResult": Array [ - "0", - "3", - "101", - "2", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented CHAR_AT works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(char_at(\\"test\\", 1));", - "displayResult": Array [ - "\\"e\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented DISPLAY throws error if no arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "display();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: \\"Expected 1 or more arguments, but got 0.\\"", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented DISPLAY works for circular references: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const p = pair(1,2); -const q = pair(3,4); -set_head(q,p); -set_tail(p,q); -display(p);", - "displayResult": Array [ - "[1, [..., 4]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented DISPLAY_LIST works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display_list(pair(1, null)); -display_list(pair(1, pair(2, null)), \\"test\\");", - "displayResult": Array [ - "list(1)", - "test list(1, 2)", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented DRAW_DATA returns correct values: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(draw_data(pair(true, [1]))); -display(draw_data(null, list(undefined, 2), \\"3\\"));", - "displayResult": Array [ - "[true, [1]]", - "null", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [ - Array [ - Array [ - true, - Array [ - 1, - ], - ], - ], - Array [ - null, - Array [ - undefined, - Array [ - 2, - null, - ], - ], - "3", - ], - ], -} -`; - -exports[`primitive opcodes self-implemented DRAW_DATA throws error if no arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "draw_data();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: \\"Expected 1 or more arguments, but got 0.\\"", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented DRAW_DATA works: expectVisualiseListResult 1`] = ` -Object { - "alertResult": Array [], - "code": "draw_data(pair(true, [1])); -draw_data(null, list(undefined, 2), \\"3\\");", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [ - Array [ - Array [ - true, - Array [ - 1, - ], - ], - ], - Array [ - null, - Array [ - undefined, - Array [ - 2, - null, - ], - ], - "3", - ], - ], -} -`; - -exports[`primitive opcodes self-implemented ERROR works: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "error(123);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: 123", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_ARRAY works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_array([1,2])); -display(is_array(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_BOOL works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_boolean(true)); -display(is_boolean(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_FUNC works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_function(() => {})); -display(is_function(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_NULL works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_null(null)); -display(is_null(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_NUMBER works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_number(1)); -display(is_number(false));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_STRING works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_string(\\"string\\")); -display(is_string(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented IS_UNDEFINED works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(is_undefined(undefined)); -display(is_undefined(1));", - "displayResult": Array [ - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented MATH_HYPOT works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(math_hypot(3,4));", - "displayResult": Array [ - "5", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented list works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(list(1,2,3,4));", - "displayResult": Array [ - "[1, [2, [3, [4, null]]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes self-implemented stream_tail fails for ill-typed arguments: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "stream_tail(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: \\"stream_tail(xs) expects a pair as argument xs, but encountered 1\\"", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`primitive opcodes unary handler: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(math_abs(-1));", - "displayResult": Array [ - "1", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes ADDG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1+undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected string and string or number and number, got number and undefined for +.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes ADDG works for numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(-1+1);", - "displayResult": Array [ - "0", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes ADDG works for strings: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(\\"first\\"+\\"second\\");", - "displayResult": Array [ - "\\"firstsecond\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes BRF works, no else 2: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (false) { - display(\\"should not show\\"); -} -display(\\"should show\\");", - "displayResult": Array [ - "\\"should show\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes BRF works, no else: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) { - display('did not BRF'); -}", - "displayResult": Array [ - "\\"did not BRF\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes BRF works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "if (true) { - display('did not BRF'); -} else {} -if (false) {} else { - display('BRF'); -}", - "displayResult": Array [ - "\\"did not BRF\\"", - "\\"BRF\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes DIVG fails for division by 0: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "128/0;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: division by 0", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes DIVG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1/undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected number and number, got number and undefined for /.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes DIVG works for numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(128/32);", - "displayResult": Array [ - "4", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes EQG works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = [1,2]; -const f = () => {}; -const y = test_and_set; -const z = list; -display(undefined === undefined && -null === null && -null !== undefined && -true === true && -false === false && -false !== true && -1 === 1 && --1 === -1 && -x !== [1,2] && -x === x && -f === f && -f !== (() => {}) && -'stringa' === 'stringa' && -'stringa' !== 'stringb' && -true !== null && -y !== z && -z === list && -y === test_and_set && -0 !== \\"0\\");", - "displayResult": Array [ - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GEG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1>=undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected string and string or number and number, got number and undefined for >=.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GEG works for numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(5 >= 10); -display(5 >= 5); -display(10 >= 5);", - "displayResult": Array [ - "false", - "true", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GEG works for numbers: expectDisplayResult 2`] = ` -Object { - "alertResult": Array [], - "code": "display('abc' >= 'bcd'); -display('abc' >= 'abc'); -display('bcd' >= 'abc');", - "displayResult": Array [ - "false", - "true", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GTG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1>undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected string and string or number and number, got number and undefined for >.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GTG works for numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(5 > 10); display(10 > 5);", - "displayResult": Array [ - "false", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes GTG works for strings: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(\\"abc\\" > \\"bcd\\"); display(\\"bcd\\" > \\"abc\\");", - "displayResult": Array [ - "false", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LDAG fails for ill-typed argument: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const arr = []; arr[\\"hi\\"];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected number, got string for array index.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LDAG fails for non-array: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1[0];", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected array, got number for array access.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LDPG and STPG work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 1; -display(x); -function f() { - x = 3; -} -f(); -display(x);", - "displayResult": Array [ - "1", - "3", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LEG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1<=undefined;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected string and string or number and number, got number and undefined for <=.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LEG works for numbers: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(5 <= 10); -display(5 <= 5); -display(10 <= 5);", - "displayResult": Array [ - "true", - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LEG works for strings: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display('abc' <= 'bcd'); -display('abc' <= 'abc'); -display('bcd' <= 'abc');", - "displayResult": Array [ - "true", - "true", - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCB0 works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(false);", - "displayResult": Array [ - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCB1 works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(true);", - "displayResult": Array [ - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCF64 works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(1.5);", - "displayResult": Array [ - "1.5", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCI works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(123);", - "displayResult": Array [ - "123", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCN works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(null);", - "displayResult": Array [ - "null", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCS works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(\\"test string\\");", - "displayResult": Array [ - "\\"test string\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LGCU works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(undefined);", - "displayResult": Array [ - "undefined", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes LTG fails for ill-typed operands: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "1\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard opcodes while loops works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 0; -const y = 'before NEWENV'; -display(y); -while (x < 1) { - const y = 'after NEWENV'; - display(y); - x = x + 1; - display('before BR'); -} -display('after POPENV'); -display('after BR');", - "displayResult": Array [ - "\\"before NEWENV\\"", - "\\"after NEWENV\\"", - "\\"before BR\\"", - "\\"after POPENV\\"", - "\\"after BR\\"", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution arrow function definitions work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const f = x => { - display(x); - return 1; -}; -const g = x => display(x); -f(3); -g(true);", - "displayResult": Array [ - "3", - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution block scoping works, part 2: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "{ - let i = 5; -} -display(i);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 4: Name i not declared.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution block scoping works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = 1; -function f(y) { - display(-x); -} -{ - const x = 2; - function f(y) { - display(-x); - } - { - const x = 3; - if (true) { - display(x); - } else { - error('should not reach here'); - } - display(x); - f(1); - } - display(x); -} -display(x);", - "displayResult": Array [ - "3", - "3", - "-2", - "2", - "1", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution call non function value throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = 0; x(1,2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: calling non-function value 0.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution closures declared in for loops work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let f = null; -f = () => { display(-1); }; -for(let i = 0; i < 5; i = i + 1) { - if (i === 3) { - f = () => { display(i); }; - } else {} -} -f();", - "displayResult": Array [ - "3", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution const assignment throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = 1; -x = 2;", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Line 2: Cannot assign new value to constant x.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution continue and break works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "while(true) { - break; - display(1); -} -let i = 0; -for (i; i < 2; i = i + 1) { - if (i === 1) { - continue; - } else { - display(i); - } -}", - "displayResult": Array [ - "0", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution continue in while loops works: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "let x = false; -while (true) { - if (x) { - break; - } else { - x = true; - } - continue; -} -display(0);", - "displayResult": Array [ - "0", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution list functions work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function permutations(xs) { - return is_null(xs) - ? list(null) - : accumulate(append, - null, - map(x => map(p => pair(x, p), - permutations(remove(x,xs))), - xs)); -} - -display(permutations(list(1,2,3)));", - "displayResult": Array [ - "[ [1, [2, [3, null]]], -[ [1, [3, [2, null]]], -[ [2, [1, [3, null]]], -[[2, [3, [1, null]]], [[3, [1, [2, null]]], [[3, [2, [1, null]]], null]]]]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution logical operators work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "display(!(true && (false || (true && !false))));", - "displayResult": Array [ - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution nested for loops with same identifier work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 3; i = i + 1) { - for (let i = 0; i < 3; i = i + 1) { - display(i, \\"inner\\"); - } - display(i, \\"outer\\"); -}", - "displayResult": Array [ - "inner 0", - "inner 1", - "inner 2", - "outer 0", - "inner 0", - "inner 1", - "inner 2", - "outer 1", - "inner 0", - "inner 1", - "inner 2", - "outer 2", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution nested for loops work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "for (let i = 0; i < 10; i = i + 1) { - for (let j = 0; j < 10; j = j + 1) {} - display(i); -}", - "displayResult": Array [ - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution program always returns all threads terminated: expectResult 1`] = ` -Object { - "alertResult": Array [], - "code": "1 + 1;", - "displayResult": Array [], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution program times out: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "while(true) {}", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Potential infinite loop detected. - If you are certain your program is correct, press run again without editing your program. - The time limit will be increased from 1 to 10 seconds. - This page may be unresponsive for up to 10 seconds if you do so.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution return in loop throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - while(true) { - return 1; - } -} -f();", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: return not allowed in loops", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution stream functions work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function interleave_stream_append(s1,s2) { - return is_null(s1) - ? s2 - : pair(head(s1), () => interleave_stream_append(s2, - stream_tail(s1))); -} - -function stream_pairs(s) { - return (is_null(s) || is_null(stream_tail(s))) - ? null - : pair(pair(head(s), head(stream_tail(s))), - () => interleave_stream_append( - stream_map(x => pair(head(s), x), - stream_tail(stream_tail(s))), - stream_pairs(stream_tail(s)))); -} - -const ints = integers_from(1); -const s = stream_pairs(ints); -display(eval_stream(s, 10));", - "displayResult": Array [ - "[ [1, 2], -[ [1, 3], -[ [2, 3], -[[1, 4], [[2, 4], [[1, 5], [[3, 4], [[1, 6], [[2, 5], [[1, 7], null]]]]]]]]]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution tail call for internal functions work: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "function f() { - return test_and_set(list(true)); -} -display(f());", - "displayResult": Array [ - "true", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution treat internal functions as first-class: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = test_and_set; -const xs = list(false); -display(x(xs));", - "displayResult": Array [ - "false", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution treat primitive functions as first-class: expectDisplayResult 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = list; -display(x(1,2));", - "displayResult": Array [ - "[1, [2, null]]", - ], - "numErrors": 0, - "parsedErrors": "", - "result": "all threads terminated", - "resultStatus": "finished", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution wrong number of arguments for internal functions throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "const x = list(false); -test_and_set(x, 1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution wrong number of arguments for normal functions throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "((x, y) => 1)(1);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected 2 arguments, but got 1.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; - -exports[`standard program execution wrong number of arguments for primitive functions throws error: expectParsedError 1`] = ` -Object { - "alertResult": Array [], - "code": "math_sin(1,2);", - "displayResult": Array [], - "numErrors": 1, - "parsedErrors": "Error: execution aborted: Expected 1 arguments, but got 2.", - "result": undefined, - "resultStatus": "error", - "visualiseListResult": Array [], -} -`; diff --git a/src/vm/__tests__/svml-machine.ts b/src/vm/__tests__/svml-machine.ts deleted file mode 100644 index 8d94829b9..000000000 --- a/src/vm/__tests__/svml-machine.ts +++ /dev/null @@ -1,1577 +0,0 @@ -import { Chapter, Variant } from '../../types' -import { stripIndent } from '../../utils/formatters' -import { - expectDisplayResult, - expectParsedError, - expectResult, - expectVisualiseListResult, - getDisplayResult, - snapshotSuccess -} from '../../utils/testing' - -// concurrent programs return undefined so use display -// for tests instead -// all tests assumes display works -// comments mention additional opcodes tested by test code -describe('standard opcodes', () => { - test('LGCI works', () => { - return expectDisplayResult(`display(123);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "123", - ] - `) - }) - - test('LGCF64 works', () => { - return expectDisplayResult(`display(1.5);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "1.5", - ] - `) - }) - - test('LGCB0 works', () => { - return expectDisplayResult(`display(false);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "false", - ] - `) - }) - - test('LGCB1 works', () => { - return expectDisplayResult(`display(true);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "true", - ] - `) - }) - - test('LGCU works', () => { - return expectDisplayResult(`display(undefined);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "undefined", - ] - `) - }) - - test('LGCN works', () => { - return expectDisplayResult(`display(null);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "null", - ] - `) - }) - - test('LGCS works', () => { - return expectDisplayResult(`display("test string");`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "\\"test string\\"", - ] - `) - }) - - test('ADDG works for numbers', () => { - return expectDisplayResult('display(-1+1);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "0", - ] - `) - }) - - test('ADDG works for strings', () => { - return expectDisplayResult('display("first"+"second");', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "\\"firstsecond\\"", - ] - `) - }) - - test('ADDG fails for ill-typed operands', () => { - return expectParsedError('1+undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected string and string or number and number, got number and undefined for +."` - ) - }) - - test('SUBG works for numbers', () => { - return expectDisplayResult('display(123-124);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "-1", - ] - `) - }) - - test('SUBG fails for ill-typed operands', () => { - return expectParsedError('1-undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected number and number, got number and undefined for -."` - ) - }) - - test('MULG works for numbers', () => { - return expectDisplayResult('display(123*2);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "246", - ] - `) - }) - - test('MULG fails for ill-typed operands', () => { - return expectParsedError('1*undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected number and number, got number and undefined for *."` - ) - }) - - test('DIVG works for numbers', () => { - return expectDisplayResult('display(128/32);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "4", - ] - `) - }) - - test('DIVG fails for division by 0', () => { - return expectParsedError('128/0;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: division by 0"`) - }) - - test('DIVG fails for ill-typed operands', () => { - return expectParsedError('1/undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected number and number, got number and undefined for /."` - ) - }) - - test('MODG works for numbers', () => { - return expectDisplayResult('display(128%31);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "4", - ] - `) - }) - - test('MODG fails for ill-typed operands', () => { - return expectParsedError('1%undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected undefined, got undefined for undefined."` - ) - }) - - test('NEGG works', () => { - return expectDisplayResult('display(-1);display(-(-1));', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "-1", - "1", - ] - `) - }) - - test('NEGG fails for ill-typed operands', () => { - return expectParsedError('-"hi";', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: Expected number, got string for -."`) - }) - - test('NOTG works', () => { - return expectDisplayResult('display(!false);display(!true);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('NOTG fails for ill-typed operands', () => { - return expectParsedError('!1;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: Expected boolean, got number for !."`) - }) - - test('LTG works for numbers', () => { - return expectDisplayResult('display(5 < 10); display(10 < 5);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('LTG works for strings', () => { - return expectDisplayResult('display("abc" < "bcd"); display("bcd" < "abc");', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('LTG fails for ill-typed operands', () => { - return expectParsedError('1 { - return expectDisplayResult('display(5 > 10); display(10 > 5);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "false", - "true", - ] - `) - }) - - test('GTG works for strings', () => { - return expectDisplayResult('display("abc" > "bcd"); display("bcd" > "abc");', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "false", - "true", - ] - `) - }) - - test('GTG fails for ill-typed operands', () => { - return expectParsedError('1>undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected string and string or number and number, got number and undefined for >."` - ) - }) - - test('LEG works for numbers', () => { - return expectDisplayResult( - stripIndent` - display(5 <= 10); - display(5 <= 5); - display(10 <= 5); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "true", - "true", - "false", - ] - `) - }) - - test('LEG works for strings', () => { - return expectDisplayResult( - stripIndent` - display('abc' <= 'bcd'); - display('abc' <= 'abc'); - display('bcd' <= 'abc'); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "true", - "true", - "false", - ] - `) - }) - - test('LEG fails for ill-typed operands', () => { - return expectParsedError('1<=undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected string and string or number and number, got number and undefined for <=."` - ) - }) - - test('GEG works for numbers', () => { - return expectDisplayResult( - stripIndent` - display(5 >= 10); - display(5 >= 5); - display(10 >= 5); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "false", - "true", - "true", - ] - `) - }) - - test('GEG works for numbers', () => { - return expectDisplayResult( - stripIndent` - display('abc' >= 'bcd'); - display('abc' >= 'abc'); - display('bcd' >= 'abc'); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "false", - "true", - "true", - ] - `) - }) - - test('GEG fails for ill-typed operands', () => { - return expectParsedError('1>=undefined;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected string and string or number and number, got number and undefined for >=."` - ) - }) - - // NEWC, CALL, RETG - test('function and function calls work', () => { - return expectDisplayResult( - stripIndent` - function f(x) { - display(x); - return 1; - } - display(f(3)); - display(f); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "3", - "1", - "\\"\\"", - ] - `) - }) - - test('STLG and LDLG works', () => { - return expectDisplayResult(`const x = 1; display(x);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "1", - ] - `) - }) - - // NEWA, LDAG, STAG, DUP - test('array opcodes work', () => { - return expectDisplayResult(`const x = [1,2,3,1]; display(x[1]); display(x[8]);`, { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "2", - "undefined", - ] - `) - }) - - test('LDAG fails for non-array', () => { - return expectParsedError('1[0];', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected array, got number for array access."` - ) - }) - - test('LDAG fails for ill-typed argument', () => { - return expectParsedError('const arr = []; arr["hi"];', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected number, got string for array index."` - ) - }) - - test('STAG fails for non-array', () => { - return expectParsedError('0[1] = 1;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected array, got number for array access."` - ) - }) - - test('STAG fails for ill-typed argument', () => { - return expectParsedError('const arr = []; arr["hi"] = 1;', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected number, got string for array index."` - ) - }) - - test('EQG works', () => { - return expectDisplayResult( - stripIndent` - const x = [1,2]; - const f = () => {}; - const y = test_and_set; - const z = list; - display(undefined === undefined && - null === null && - null !== undefined && - true === true && - false === false && - false !== true && - 1 === 1 && - -1 === -1 && - x !== [1,2] && - x === x && - f === f && - f !== (() => {}) && - 'stringa' === 'stringa' && - 'stringa' !== 'stringb' && - true !== null && - y !== z && - z === list && - y === test_and_set && - 0 !== "0"); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - ] - `) - }) - - test('LDPG and STPG work', () => { - return expectDisplayResult( - stripIndent` - let x = 1; - display(x); - function f() { - x = 3; - } - f(); - display(x); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "1", - "3", - ] - `) - }) - - test('BRF works', () => { - return expectDisplayResult( - stripIndent` - if (true) { - display('did not BRF'); - } else {} - if (false) {} else { - display('BRF'); - } - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "\\"did not BRF\\"", - "\\"BRF\\"", - ] - `) - }) - - test('BRF works, no else', () => { - return expectDisplayResult( - stripIndent` - if (true) { - display('did not BRF'); - } - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "\\"did not BRF\\"", - ] - `) - }) - - test('BRF works, no else 2', () => { - return expectDisplayResult( - stripIndent` - if (false) { - display("should not show"); - } - display("should show"); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "\\"should show\\"", - ] - `) - }) - - // BR, NEWENV, POPENV - test('while loops works', () => { - return expectDisplayResult( - stripIndent` - let x = 0; - const y = 'before NEWENV'; - display(y); - while (x < 1) { - const y = 'after NEWENV'; - display(y); - x = x + 1; - display('before BR'); - } - display('after POPENV'); - display('after BR'); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "\\"before NEWENV\\"", - "\\"after NEWENV\\"", - "\\"before BR\\"", - "\\"after POPENV\\"", - "\\"after BR\\"", - ] - `) - }) -}) - -describe('primitive opcodes', () => { - describe('self-implemented', () => { - test('DISPLAY works for circular references', () => { - return expectDisplayResult( - stripIndent` - const p = pair(1,2); - const q = pair(3,4); - set_head(q,p); - set_tail(p,q); - display(p); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "[1, [..., 4]]", - ] - `) - }) - - test('DISPLAY throws error if no arguments', () => { - return expectParsedError( - stripIndent` - display(); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(`"Error: \\"Expected 1 or more arguments, but got 0.\\""`) - }) - - test('ARRAY_LEN works', () => { - return expectDisplayResult( - stripIndent` - const arr = []; - const arr1 = [1,2,3]; - const p = pair(1,2); - display(array_length(arr)); - display(array_length(arr1)); - arr[100] = 100; - display(array_length(arr)); - display(array_length(p)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "0", - "3", - "101", - "2", - ] - `) - }) - - test('ARRAY_LEN fails for ill-typed argument', () => { - return expectParsedError('array_length(1);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected array, got number for array_length."` - ) - }) - - test('DRAW_DATA works', () => { - return expectVisualiseListResult( - stripIndent` - draw_data(pair(true, [1])); - draw_data(null, list(undefined, 2), "3"); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - Array [ - Array [ - true, - Array [ - 1, - ], - ], - ], - Array [ - null, - Array [ - undefined, - Array [ - 2, - null, - ], - ], - "3", - ], - ] - `) - }) - - test('DRAW_DATA returns correct values', () => { - return expectDisplayResult( - stripIndent` - display(draw_data(pair(true, [1]))); - display(draw_data(null, list(undefined, 2), "3")); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "[true, [1]]", - "null", - ] - `) - }) - - test('DRAW_DATA throws error if no arguments', () => { - return expectParsedError( - stripIndent` - draw_data(); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(`"Error: \\"Expected 1 or more arguments, but got 0.\\""`) - }) - - test('ERROR works', () => { - return expectParsedError('error(123);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: 123"`) - }) - - test('IS_ARRAY works', () => { - return expectDisplayResult( - stripIndent` - display(is_array([1,2])); - display(is_array(1)); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_BOOL works', () => { - return expectDisplayResult( - stripIndent` - display(is_boolean(true)); - display(is_boolean(1)); - `, - { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_FUNC works', () => { - return expectDisplayResult( - stripIndent` - display(is_function(() => {})); - display(is_function(1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_NULL works', () => { - return expectDisplayResult( - stripIndent` - display(is_null(null)); - display(is_null(1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_NUMBER works', () => { - return expectDisplayResult( - stripIndent` - display(is_number(1)); - display(is_number(false)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_STRING works', () => { - return expectDisplayResult( - stripIndent` - display(is_string("string")); - display(is_string(1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('IS_UNDEFINED works', () => { - return expectDisplayResult( - stripIndent` - display(is_undefined(undefined)); - display(is_undefined(1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - // variadic test as well - test('MATH_HYPOT works', () => { - return expectDisplayResult( - stripIndent` - display(math_hypot(3,4)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "5", - ] - `) - }) - - test('DISPLAY_LIST works', () => { - return expectDisplayResult( - stripIndent` - display_list(pair(1, null)); - display_list(pair(1, pair(2, null)), "test"); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "list(1)", - "test list(1, 2)", - ] - `) - }) - - test('CHAR_AT works', () => { - return expectDisplayResult( - stripIndent` - display(char_at("test", 1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "\\"e\\"", - ] - `) - }) - - test('ARITY works', () => { - return expectDisplayResult( - stripIndent` - display(arity(math_random)); - display(arity(accumulate)); - display(arity(display)); - display(arity((x, y) => x)); - function f() {} - display(arity(f)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "0", - "3", - "0", - "2", - "0", - ] - `) - }) - - test('ARITY fails for ill-typed argument', () => { - return expectParsedError('arity(1);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot( - `"Error: execution aborted: Expected closure, got number for arity."` - ) - }) - - // variadic test - test('list works', () => { - return expectDisplayResult( - stripIndent` - display(list(1,2,3,4)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "[1, [2, [3, [4, null]]]]", - ] - `) - }) - - test('stream_tail fails for ill-typed arguments', () => { - return expectParsedError( - stripIndent` - stream_tail(1); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot( - `"Error: \\"stream_tail(xs) expects a pair as argument xs, but encountered 1\\""` - ) - }) - }) - - test('nullary handler', () => { - return snapshotSuccess('get_time();', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }) - }) - - test('unary handler', () => { - return expectDisplayResult( - stripIndent` - display(math_abs(-1)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "1", - ] - `) - }) - - test('binary handler', () => { - return expectDisplayResult( - stripIndent` - display(math_pow(2,3)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "8", - ] - `) - }) - - test('math constants', () => { - return expectDisplayResult( - stripIndent` - display(Infinity); - display(NaN); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "Infinity", - "NaN", - ] - `) - }) - - describe(Variant.CONCURRENT, () => { - test('TEST_AND_SET works', () => { - return expectDisplayResult( - stripIndent` - const x = list(false); - display(head(x)); - test_and_set(x); - display(head(x)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "false", - "true", - ] - `) - }) - - test('TEST_AND_SET fails for ill-typed arguments', () => { - return expectParsedError( - stripIndent` - test_and_set(1); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot( - `"Error: execution aborted: Expected array, got number for test_and_set."` - ) - }) - - test('CLEAR works', () => { - return expectDisplayResult( - stripIndent` - const x = list(true); - display(head(x)); - clear(x); - display(head(x)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - "false", - ] - `) - }) - - test('CLEAR fails for ill-typed arguments', () => { - return expectParsedError( - stripIndent` - clear(1); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(`"Error: execution aborted: Expected array, got number for clear."`) - }) - }) -}) - -describe('standard program execution', () => { - test('program always returns all threads terminated', () => { - return expectResult('1 + 1;', { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT }).toBe( - 'all threads terminated' - ) - }) - - test('arrow function definitions work', () => { - return expectDisplayResult( - stripIndent` - const f = x => { - display(x); - return 1; - }; - const g = x => display(x); - f(3); - g(true); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "3", - "true", - ] - `) - }) - - test('logical operators work', () => { - return expectDisplayResult('display(!(true && (false || (true && !false))));', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - Array [ - "false", - ] - `) - }) - - test('&& operator shortcircuit works', () => { - return snapshotSuccess( - stripIndent` - function f() { - f(); - } - false && f(); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ) - }) - - test('|| operator shortcircuit works', () => { - return snapshotSuccess( - stripIndent` - function f() { - f(); - } - true || f(); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ) - }) - - test('list functions work', () => { - return expectDisplayResult( - stripIndent` - function permutations(xs) { - return is_null(xs) - ? list(null) - : accumulate(append, - null, - map(x => map(p => pair(x, p), - permutations(remove(x,xs))), - xs)); - } - - display(permutations(list(1,2,3))); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "[ [1, [2, [3, null]]], - [ [1, [3, [2, null]]], - [ [2, [1, [3, null]]], - [[2, [3, [1, null]]], [[3, [1, [2, null]]], [[3, [2, [1, null]]], null]]]]]]", - ] - `) - }) - - // taken from Studio 11 - test('stream functions work', () => { - return expectDisplayResult( - stripIndent` - function interleave_stream_append(s1,s2) { - return is_null(s1) - ? s2 - : pair(head(s1), () => interleave_stream_append(s2, - stream_tail(s1))); - } - - function stream_pairs(s) { - return (is_null(s) || is_null(stream_tail(s))) - ? null - : pair(pair(head(s), head(stream_tail(s))), - () => interleave_stream_append( - stream_map(x => pair(head(s), x), - stream_tail(stream_tail(s))), - stream_pairs(stream_tail(s)))); - } - - const ints = integers_from(1); - const s = stream_pairs(ints); - display(eval_stream(s, 10)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "[ [1, 2], - [ [1, 3], - [ [2, 3], - [[1, 4], [[2, 4], [[1, 5], [[3, 4], [[1, 6], [[2, 5], [[1, 7], null]]]]]]]]]]", - ] - `) - }) - - test('program times out', () => { - return expectParsedError('while(true) {}', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(` - "Potential infinite loop detected. - If you are certain your program is correct, press run again without editing your program. - The time limit will be increased from 1 to 10 seconds. - This page may be unresponsive for up to 10 seconds if you do so." - `) - }) - - test('block scoping works', () => { - return expectDisplayResult( - stripIndent` - const x = 1; - function f(y) { - display(-x); - } - { - const x = 2; - function f(y) { - display(-x); - } - { - const x = 3; - if (true) { - display(x); - } else { - error('should not reach here'); - } - display(x); - f(1); - } - display(x); - } - display(x); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "3", - "3", - "-2", - "2", - "1", - ] - `) - }) - - test('block scoping works, part 2', () => { - return expectParsedError( - stripIndent` - { - let i = 5; - } - display(i); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(`"Line 4: Name i not declared."`) - }) - - test('return in loop throws error', () => { - return expectParsedError( - stripIndent` - function f() { - while(true) { - return 1; - } - } - f(); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(`"Error: return not allowed in loops"`) - }) - - test('continue and break works', () => { - return expectDisplayResult( - stripIndent` - while(true) { - break; - display(1); - } - let i = 0; - for (i; i < 2; i = i + 1) { - if (i === 1) { - continue; - } else { - display(i); - } - } - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "0", - ] - `) - }) - - test('const assignment throws error', () => { - return expectParsedError( - stripIndent` - const x = 1; - x = 2; - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(`"Line 2: Cannot assign new value to constant x."`) - }) - - test('treat primitive functions as first-class', () => { - return expectDisplayResult( - stripIndent` - const x = list; - display(x(1,2)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "[1, [2, null]]", - ] - `) - }) - - test('treat internal functions as first-class', () => { - return expectDisplayResult( - stripIndent` - const x = test_and_set; - const xs = list(false); - display(x(xs)); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "false", - ] - `) - }) - - test('wrong number of arguments for internal functions throws error', () => { - return expectParsedError( - stripIndent` - const x = list(false); - test_and_set(x, 1); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(`"Error: execution aborted: Expected 1 arguments, but got 2."`) - }) - - test('wrong number of arguments for normal functions throws error', () => { - return expectParsedError('((x, y) => 1)(1);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: Expected 2 arguments, but got 1."`) - }) - - test('wrong number of arguments for primitive functions throws error', () => { - return expectParsedError('math_sin(1,2);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: Expected 1 arguments, but got 2."`) - }) - - test('call non function value throws error', () => { - return expectParsedError('let x = 0; x(1,2);', { - chapter: Chapter.SOURCE_3, - variant: Variant.CONCURRENT - }).toMatchInlineSnapshot(`"Error: execution aborted: calling non-function value 0."`) - }) - - test('tail call for internal functions work', () => { - return expectDisplayResult( - stripIndent` - function f() { - return test_and_set(list(true)); - } - display(f()); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "true", - ] - `) - }) - - test('closures declared in for loops work', () => { - return expectDisplayResult( - stripIndent` - let f = null; - f = () => { display(-1); }; - for(let i = 0; i < 5; i = i + 1) { - if (i === 3) { - f = () => { display(i); }; - } else {} - } - f(); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "3", - ] - `) - }) - - test('nested for loops work', () => { - return expectDisplayResult( - stripIndent` - for (let i = 0; i < 10; i = i + 1) { - for (let j = 0; j < 10; j = j + 1) {} - display(i); - } - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - ] - `) - }) - - test('nested for loops with same identifier work', () => { - return expectDisplayResult( - stripIndent` - for (let i = 0; i < 3; i = i + 1) { - for (let i = 0; i < 3; i = i + 1) { - display(i, "inner"); - } - display(i, "outer"); - } - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "inner 0", - "inner 1", - "inner 2", - "outer 0", - "inner 0", - "inner 1", - "inner 2", - "outer 1", - "inner 0", - "inner 1", - "inner 2", - "outer 2", - ] - `) - }) - - test('continue in while loops works', () => { - return expectDisplayResult( - stripIndent` - let x = false; - while (true) { - if (x) { - break; - } else { - x = true; - } - continue; - } - display(0); - `, - { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT } - ).toMatchInlineSnapshot(` - Array [ - "0", - ] - `) - }) -}) - -// fails with a large enough TO -test('concurrent program execution interleaves', () => { - const code = stripIndent` - const t1 = () => { - for(let i = 0; i < 50; i = i + 1) { - display('t1'); - } - }; - const t2 = () => { - for(let i = 0; i < 50; i = i + 1) { - display('t2'); - } - }; - concurrent_execute(t1, t2); - for(let i = 0; i < 50; i = i + 1) { - display('main'); - } - ` - return getDisplayResult(code, { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT }).then( - displayResult => { - // check for interleaving displays of main, t1 and t2 - // done by looking for 't1' and 't2' somewhere between two 'main' displays - let firstMain = -1 - let foundT1 = false - let foundT2 = false - for (let i = 0; i < displayResult.length; i++) { - const currentResult = displayResult[i] - switch (currentResult) { - case '"main"': { - if (firstMain === -1) { - firstMain = i - continue - } - if (foundT1 && foundT2) { - return - } - continue - } - case '"t1"': { - if (firstMain === -1) { - continue - } - foundT1 = true - continue - } - case '"t2"': { - if (firstMain === -1) { - continue - } - foundT2 = true - continue - } - default: { - fail('Did not expect "' + currentResult + '" in output') - } - } - } - fail('Did not interleave') - } - ) -}) - -// Still fails when TO is so large that this program takes more than a second to run -test('concurrent program execution interleaves (busy wait)', () => { - const code = stripIndent` - let state = 0; - const t1 = () => { - while (state < 10) { - if (state % 3 === 0) { - state = state + 1; - } else {} - display('t1'); - } - }; - const t2 = () => { - while (state < 10) { - if (state % 3 === 1) { - state = state + 1; - } else {} - display('t2'); - } - }; - concurrent_execute(t1, t2); - while (state < 10) { - if (state % 3 === 2) { - state = state + 1; - } else {} - display('main'); - } - ` - return getDisplayResult(code, { chapter: Chapter.SOURCE_3, variant: Variant.CONCURRENT }) -}) diff --git a/src/vm/svmc.ts b/src/vm/svmc.ts deleted file mode 100644 index 0fe160ce1..000000000 --- a/src/vm/svmc.ts +++ /dev/null @@ -1,231 +0,0 @@ -import * as fs from 'fs' -import * as util from 'util' - -import { createEmptyContext } from '../createContext' -import { parse } from '../parser/parser' -import { INTERNAL_FUNCTIONS as concurrentInternalFunctions } from '../stdlib/vm.prelude' -import { Chapter, Variant } from '../types' -import { assemble } from './svml-assembler' -import { compileToIns } from './svml-compiler' -import { stringifyProgram } from './util' - -interface CliOptions { - compileTo: 'debug' | 'json' | 'binary' | 'ast' - sourceChapter: Chapter.SOURCE_1 | Chapter.SOURCE_2 | Chapter.SOURCE_3 - sourceVariant: Variant.DEFAULT | Variant.CONCURRENT // does not support other variants - inputFilename: string - outputFilename: string | null - vmInternalFunctions: string[] | null -} - -const readFileAsync = util.promisify(fs.readFile) -const writeFileAsync = util.promisify(fs.writeFile) - -// This is a console program. We're going to print. -/* tslint:disable:no-console */ - -function parseOptions(): CliOptions | null { - const ret: CliOptions = { - compileTo: 'binary', - sourceChapter: Chapter.SOURCE_3, - sourceVariant: Variant.DEFAULT, - inputFilename: '', - outputFilename: null, - vmInternalFunctions: null - } - - let endOfOptions = false - let error = false - const args = process.argv.slice(2) - while (args.length > 0) { - let option = args[0] - let argument = args[1] - let argShiftNumber = 2 - if (!endOfOptions && option.startsWith('--') && option.includes('=')) { - ;[option, argument] = option.split('=') - argShiftNumber = 1 - } - if (!endOfOptions && option.startsWith('-')) { - switch (option) { - case '--compile-to': - case '-t': - switch (argument) { - case 'debug': - case 'json': - case 'binary': - case 'ast': - ret.compileTo = argument - break - default: - console.error('Invalid argument to --compile-to: %s', argument) - error = true - break - } - args.splice(0, argShiftNumber) - break - case '--chapter': - case '-c': - const argInt = parseInt(argument, 10) - if (argInt === 1 || argInt === 2 || argInt === 3) { - ret.sourceChapter = argInt - } else { - console.error('Invalid Source chapter: %d', argInt) - error = true - } - args.splice(0, argShiftNumber) - break - case '--variant': - case '-v': - switch (argument) { - case Variant.DEFAULT: - case Variant.CONCURRENT: - ret.sourceVariant = argument - break - default: - console.error('Invalid/Unsupported Source Variant: %s', argument) - error = true - break - } - args.splice(0, argShiftNumber) - break - case '--out': - case '-o': - ret.outputFilename = argument - args.splice(0, argShiftNumber) - break - case '--internals': - case '-i': - ret.vmInternalFunctions = JSON.parse(argument) - args.splice(0, argShiftNumber) - break - case '--': - endOfOptions = true - args.shift() - break - default: - console.error('Unknown option %s', option) - args.shift() - error = true - break - } - } else { - if (ret.inputFilename === '') { - ret.inputFilename = args[0] - } else { - console.error('Excess non-option argument: %s', args[0]) - error = true - } - args.shift() - } - } - - if (ret.inputFilename === '') { - console.error('No input file specified') - error = true - } - - return error ? null : ret -} - -async function main() { - const options = parseOptions() - if (options == null) { - console.error(`Usage: svmc [options...] - -Options: --t, --compile-to